當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript AngularFireDatabase.list方法代碼示例

本文整理匯總了TypeScript中angularfire2/database.AngularFireDatabase.list方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript AngularFireDatabase.list方法的具體用法?TypeScript AngularFireDatabase.list怎麽用?TypeScript AngularFireDatabase.list使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在angularfire2/database.AngularFireDatabase的用法示例。


在下文中一共展示了AngularFireDatabase.list方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: constructor

  constructor(
    private route: ActivatedRoute,
    private router: Router,
    private db: AngularFireDatabase,
    private sanitizer: DomSanitizer,
    private spotifyService: SpotifyService,
    private soundcloudService: SoundcloudService) {
    this.sanitizer = sanitizer;
    this.id = this.route.snapshot.params.id;
    this.itemsRef = db.list('items/' + this.id);
    this.forkedItems = this.itemsRef.valueChanges();
    this.items = db.list('items');
    // this.items = af.database.list('/items');
    this.playlist = [];

    this.forkedItemsSubsciption = this.forkedItems
      .subscribe(items=> {
        items.forEach((item:any) => {
          if(item.url && item.embed_url) {
            this.playlist.push({url: item.url, embed_url: item.embed_url, image_url: item.image_url});
          }
          if(item.title) {
            this.forkedTitle = item.title;
            this.title = item.title;
          }
          if(item.fork_count !== undefined) {
            this.fork_count = item.fork_count+1;
            this.forkKey = item.$key;
          }
        });
      });
  }
開發者ID:fobabett,項目名稱:TuneFork,代碼行數:32,代碼來源:forked-playlist.component.ts

示例2: constructor

  constructor(
    public af: FirebaseApp,
    public db: AngularFireDatabase,
    public snackBar: MdSnackBar,
    public globalService: GlobalService,
    public router: Router,
    public route: ActivatedRoute,
    private fb: FirebaseApp,
    public dialog: MdDialog
  ) {
    this.newPublished = false;
    this.products = db.list('/products');
    this.categories = db.list('/categories').snapshotChanges();

    this.globalService.admin.subscribe(admin => {
      this.currentAdmin = admin;

      let adminApprovalProducts = this.db.list('/approvals/products/', ref => ref.orderByChild('updatedBy').equalTo(this.currentAdmin.uid));
      adminApprovalProducts.valueChanges().subscribe(response => {
        console.log(!response);
      });
    });

    this.storageRef = af.storage().ref();
  }
開發者ID:mogeta,項目名稱:firebase-cms,代碼行數:25,代碼來源:add-product.component.ts

示例3: submitForModeration

  submitForModeration(newURL: string, newDate: string, newTitle: string, newBody: string, newPublished: boolean) {
    if (!newPublished) {
      newPublished = false;
    }

    if (newURL && newDate && newTitle && newBody && this.currentAdmin.uid) {
      let date = new Date(newDate);
      let dateTime = date.getTime();

      let approvalObject = {
        entityKey: this.router.url.includes('approval') ? this.entityObject.entityKey : this.postKey,
        url: newURL,
        dateUpdated: Date.now().toString(),
        rdateUpdated: (Date.now() * -1).toString(),
        date: dateTime,
        title: newTitle,
        thumbnail: this.newThumbnail ? this.newThumbnail : null,
        body: newBody,
        published: newPublished,
        updatedBy: this.currentAdmin.uid
      };

      if (this.editMode && this.postKey) {

        this.currentModeratedPosts = this.db.list('/approvals/posts/');

        let adminApprovalPosts = this.db.list('/approvals/posts/', ref => ref.orderByChild('updatedBy').equalTo(this.currentAdmin.uid)).valueChanges();

        adminApprovalPosts.take(1).subscribe((approvals:any) => {
          let matchingApprovals = [];
          if (this.router.url.includes('approval')) {
            matchingApprovals = approvals.filter((match) => {
              return match.entityKey === this.entityObject.entityKey;
            });
          } else {
            matchingApprovals = approvals.filter((match) => {
              return match.entityKey === this.postKey;
            });
          }

          if (matchingApprovals.length === 0 || !this.router.url.includes('approval')) {
            this.currentModeratedPosts.push(approvalObject);
          } else {
            this.db.object('/approvals/posts/' + this.postKey).update(approvalObject);
          }
        });
      } else {
          this.db.list('/approvals/posts/').push(approvalObject);
      }
      let snackBarRef = this.snackBar.open('Post submitted for moderation', 'OK!', {
        duration: 3000
      });
      snackBarRef.onAction().subscribe(() => {
        this.router.navigateByUrl('admin/approvals');
      });
    }

    this.validateFields(newURL, newTitle, newBody, newDate);
  }
開發者ID:mogeta,項目名稱:firebase-cms,代碼行數:59,代碼來源:add-post.component.ts

示例4: submitForModeration

  submitForModeration(newTitle: string, newPrice: string, newCategory: any, newWeight: number, newDescription: string, newPublished: boolean) {
    if (!newPublished) {
      newPublished = false;
    }

    if (newTitle && newPrice && newDescription && this.currentAdmin.uid) {

      let approvalObject = {
        entityKey: this.router.url.includes('approval') ? this.entityObject.entityKey : this.productKey,
        url: this.globalService.slugify(newTitle),
        dateUpdated: Date.now().toString(),
        rdateUpdated: (Date.now() * -1).toString(),
        title: newTitle,
        thumbnail: this.newThumbnail ? this.newThumbnail : null,
        description: newDescription,
        price: newPrice,
        published: newPublished,
        weight: newWeight,
        updatedBy: this.currentAdmin.uid,
        category: newCategory ? newCategory : null
      };

      if (this.editMode && this.productKey) {

        this.currentModeratedProducts = this.db.list('/approvals/products/');

        let adminApprovalProducts = this.db.list('/approvals/products/', ref => ref.orderByChild('updatedBy').equalTo(this.currentAdmin.uid)).valueChanges();
        adminApprovalProducts.take(1).subscribe((approvals:any) => {

          let matchingApprovals = [];
          if (this.router.url.includes('approval')) {
            matchingApprovals = approvals.filter((match) => {
              return match.entityKey === this.entityObject.entityKey;
            });
          } else {
            matchingApprovals = approvals.filter((match) => {
              return match.entityKey === this.productKey;
            });
          }

          if (matchingApprovals.length === 0 || !this.router.url.includes('approval')) {
            this.currentModeratedProducts.push(approvalObject);
          } else {
            this.db.object('/approvals/products/' + this.productKey).update(approvalObject);
          }
        });
      } else {
          this.db.list('/approvals/products/').push(approvalObject);
      }
      let snackBarRef = this.snackBar.open('Product submitted for moderation', 'OK!', {
        duration: 3000
      });
      snackBarRef.onAction().subscribe(() => {
        this.router.navigateByUrl('admin/approvals');
      });
    }

    this.validateFields(newTitle, newDescription, newPrice);
  }
開發者ID:mogeta,項目名稱:firebase-cms,代碼行數:59,代碼來源:add-product.component.ts

示例5: constructor

 constructor(
   public db: AngularFireDatabase,
   public route: ActivatedRoute,
   public router: Router,
   private title: Title,
   private meta: Meta
 ) {
   this.categories = db.list('/categories').valueChanges();
   this.products = db.list('/products', ref => ref.orderByChild('published').equalTo(true)).valueChanges();
   this.categoryObject = {};
 }
開發者ID:mogeta,項目名稱:firebase-cms,代碼行數:11,代碼來源:product-category.component.ts

示例6: constructor

 constructor(
   public db: AngularFireDatabase,
   public snackBar: MdSnackBar,
   public globalService: GlobalService,
   public router: Router,
   public route: ActivatedRoute
 ) {
   this.states = globalService.states;
   this.statuses = globalService.orderStatuses;
   this.orders = db.list('/orders');
   this.users = db.list('/users');
   this.order = { shipping: {}, billing: {} };
 }
開發者ID:mogeta,項目名稱:firebase-cms,代碼行數:13,代碼來源:add-order.component.ts

示例7: submitForModeration

  submitForModeration(newName: string, newWeight: number) {
    if (newName && this.currentAdmin.uid) {

      let approvalObject = {
        entityKey: this.router.url.includes('approval') ? this.entityObject.entityKey : this.categoryKey,
        name: newName,
        weight: newWeight,
        slug: this.globalService.slugify(newName),
        dateUpdated: Date.now().toString(),
        rdateUpdated: (Date.now() * -1).toString(),
        updatedBy: this.currentAdmin.uid,
        products: this.newProducts ? this.newProducts : null
      };

      if (this.editMode && this.categoryKey) {
        this.currentModeratedCategories = this.db.list('/approvals/categories/');

        let adminApprovalCategories = this.db.list('/approvals/categories/', ref => ref.orderByChild('updatedBy').equalTo(this.currentAdmin.uid)).valueChanges();

        adminApprovalCategories.take(1).subscribe((approvals:any) => {
          let matchingApprovals = [];
          if (this.router.url.includes('approval')) {
            matchingApprovals = approvals.filter((match) => {
              return match.entityKey === this.entityObject.entityKey;
            });
          } else {
            matchingApprovals = approvals.filter((match) => {
              return match.entityKey === this.categoryKey;
            });
          }

          if (matchingApprovals.length === 0 || !this.router.url.includes('approval')) {
            this.currentModeratedCategories.push(approvalObject);
          } else {
            this.db.object('/approvals/categories/' + this.categoryKey).update(approvalObject);
          }
        });
      } else {
          this.db.list('/approvals/categories/').push(approvalObject);
      }
      let snackBarRef = this.snackBar.open('Category submitted for moderation', 'OK!', {
        duration: 3000
      });
      snackBarRef.onAction().subscribe(() => {
        this.router.navigateByUrl('admin/approvals');
      });
    }

    this.validateFields(newName);
  }
開發者ID:mogeta,項目名稱:firebase-cms,代碼行數:50,代碼來源:add-product-category.component.ts

示例8: constructor

 constructor(
   public db: AngularFireDatabase,
   private title: Title,
   private meta: Meta
 ) {
   this.categories = db.list('/categories', ref => ref.orderByChild('weight').limitToLast(999)).valueChanges();
 }
開發者ID:mogeta,項目名稱:firebase-cms,代碼行數:7,代碼來源:product-categories.component.ts

示例9:

    this.route.params.subscribe((params: Params) => {
        if (params && params.key) {
          this.editMode = true;
          this.categoryKey = params.key;

          if (this.router.url.includes('approval')) {
            this.currentCategory = this.db.object('/approvals/categories/' + params.key);
            this.db.object('/approvals/categories/' + this.categoryKey).valueChanges().subscribe((approvalCategory:any) => {
              this.entityObject = approvalCategory;
            });
          } else {
            this.currentCategory = this.db.object('/categories/' + params.key);

            // check to see if any approvals are awaiting on this category
            this.db.list('/approvals/categories', ref => ref.orderByChild('entityKey').equalTo(params.key)).snapshotChanges()
              .subscribe((approval:any) => {
                if (approval.length > 0 && approval[0]) {
                  this.awaitingApproval = approval[0].key;
                }
            });
          }

          this.currentCategory.subscribe(c => {
            this.newName = c.name;
            this.newWeight = c.weight;
            if (c.products) {
              this.newProducts = c.products;
            }
          });
        } else {
          this.newName = null;
          this.newWeight = 0;
        }
    });
開發者ID:mogeta,項目名稱:firebase-cms,代碼行數:34,代碼來源:add-product-category.component.ts

示例10: if

    dialogRef.afterClosed().subscribe(result => {
      this.selectedOption = result;
      if (this.selectedOption === 'approve') {
        if (entityObject.entityKey) {
          let ogEntity = this.db.object('/' + entity + '/' + entityObject.entityKey);
          ogEntity.valueChanges().take(1).subscribe((item:any) => {
            if (entity === 'products' && item.category && entityObject.category) {
              this.db.object('/categories/' + item.category + '/products/' + entityObject.entityKey).remove();
              this.db.object('/categories/' + entityObject.category + '/products/' + entityObject.entityKey).set(Date.now().toString());
            } else if (entity === 'products' && item.category && !entityObject.category) {
              this.db.object('/categories/' + item.category + '/products/' + entityObject.entityKey).remove();
            } else if (entity === 'products' && !item.category && entityObject.category) {
              this.db.object('/categories/' + entityObject.category + '/products/' + entityObject.entityKey).set(Date.now().toString());
            }
            ogEntity.set(entityObject);
          });
        } else {
          this.db.list('/' + entity).push(entityObject).then((item) => {
            if (entity === 'products' && entityObject.category) {
              this.db.object('/categories/' + entityObject.category + '/products/' + item.key).set(Date.now().toString());
            }
          });
        }

        this.db.object('/approvals/' + entity + '/' + ogKey).remove();
        let snackBarRef = this.snackBar.open('Item approved', 'OK!', {
          duration: 3000
        });
      }
    });
開發者ID:mogeta,項目名稱:firebase-cms,代碼行數:30,代碼來源:admin-approvals.component.ts


注:本文中的angularfire2/database.AngularFireDatabase.list方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。