当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript database.AngularFireList类代码示例

本文整理汇总了TypeScript中angularfire2/database.AngularFireList的典型用法代码示例。如果您正苦于以下问题:TypeScript AngularFireList类的具体用法?TypeScript AngularFireList怎么用?TypeScript AngularFireList使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了AngularFireList类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: createPost

 /**
  * Create new post
  * @param post 
  */
 createPost(post: any) {
     this.postsRef.push({ 
         date: moment().format("MMM Do YY"),
         description: post.description,
         title: post.title
     });
   }
开发者ID:tequila1410,项目名称:AngularBlogApp,代码行数:11,代码来源:posts-list.service.ts

示例2: constructor

 constructor(private route: ActivatedRoute, private router: Router, db: AngularFireDatabase) {
   this.sub = this.route.params.subscribe(params => {
     this.id = params['id'];
   });
   this.itemsRef = db.list('items/' + this.id);
   this.items = this.itemsRef.valueChanges();
   this.playlist = [];
   this.itemsSubsrciption = this.items
     .subscribe(items=> {
       items.forEach((item: any) => {
         if(item.fork) {
           this.forked = true;
           this.forkedFrom = item.fork.forked_from;
           this.forkedTitle = item.fork.forked_from_title;
         }
         if(item.url && item.embed_url) {
           this.playlist.push({url: item.url, embed_url: item.embed_url, image_url: item.image_url, type: item.type});
         }
         if(item.title && item.createdAt) {
           this.createdAt = item.createdAt;
           this.title = item.title;
           this.fork_count = item.fork_count;
         }
       });
     });
 }
开发者ID:fobabett,项目名称:TuneFork,代码行数:26,代码来源:playlist.component.ts

示例3: addCategory

  addCategory(newName: string, newWeight: number) {
    if (newName) {
      let categoryObject = {
        name: newName,
        weight: newWeight,
        slug: this.globalService.slugify(newName),
        dateUpdated: Date.now().toString(),
        rdateUpdated: (Date.now() * -1).toString(),
        updatedBy: this.currentAdmin.uid,
        entityKey: this.editMode && this.categoryKey ? this.categoryKey : null,
        products: this.newProducts ? this.newProducts : null
      };

      if (this.editMode && this.categoryKey) {
        this.db.object('/categories/' + this.categoryKey).update(categoryObject);
      } else {
        this.categories.push(categoryObject).then((item) => {
          this.db.object('/categories/' + item.key + '/entityKey').set(item.key);
        });
      }

      let snackBarRef = this.snackBar.open('Category saved', 'OK!', {
        duration: 3000
      });

    }
    this.validateFields(newName);
  }
开发者ID:mogeta,项目名称:firebase-cms,代码行数:28,代码来源:add-product-category.component.ts

示例4: 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

示例5: save

 save(playlistTitle: any) {
   let date = new Date().toString();
   this.playlist.push({title: playlistTitle._value, createdAt: date, fork_count: 0});
 	let newPlaylistRef = this.itemsRef.push(this.playlist);
   let playlistID = newPlaylistRef.key;
   // this.airshipService.createAerostat(playlistID);
   this.router.navigate(['/playlist/view/', playlistID]);
 }
开发者ID:fobabett,项目名称:TuneFork,代码行数:8,代码来源:create-playlist.component.ts

示例6: resolve

 }).then((_uidDQ: any) => {
   this.listOfCTs$ = this.db.list(`/`);
   this.listOfCTs$.valueChanges().subscribe(_CTs => {
     _CTs.forEach(_DQs => {
       if(_DQs['users'] != undefined)
         if (_DQs['users'][_uidDQ] != undefined)
           resolve(_DQs['users'][_uidDQ]);
     })
   })
 })
开发者ID:dekonunes,项目名称:ConneCT-App,代码行数:10,代码来源:user.service.ts

示例7: constructor

 constructor(
   public navCtrl: NavController,
   public alertCtrl: AlertController,
   public database: AngularFireDatabase
 ) {
   this.tasksRef = this.database.list('tasks');
   this.tasks = this.tasksRef.snapshotChanges()
   .map(changes => {
     return changes.map(c => ({ key: c.payload.key, ...c.payload.val() }));
   });
 }
开发者ID:ion-book,项目名称:demo104,代码行数:11,代码来源:home.ts

示例8: addOrder

  addOrder(newOrder) {
    if (newOrder) {
      if (this.editMode && this.orderKey) {
        this.db.object('/orders/' + this.orderKey).update(newOrder);
      } else {
        this.orders.push(newOrder);
      }

      let snackBarRef = this.snackBar.open('Order saved', 'OK!', {
        duration: 3000
      });
    }
  }
开发者ID:mogeta,项目名称:firebase-cms,代码行数:13,代码来源:add-order.component.ts

示例9:

 adminApprovalPages.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.pageKey;
     });
   }
   if (matchingApprovals.length === 0 || !this.router.url.includes('approval')) {
     this.currentModeratedPages.push(approvalObject);
   } else {
     this.db.object('/approvals/pages/' + this.pageKey).update(approvalObject);
   }
 });
开发者ID:mogeta,项目名称:firebase-cms,代码行数:17,代码来源:add-page.component.ts

示例10: addProduct

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

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

      let productObject = {
        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,
        updatedBy: this.currentAdmin.uid,
        weight: newWeight,
        category: newCategory ? newCategory : null,
        entityKey: this.editMode && this.productKey ? this.productKey : null
      };

      // if (this.imageUrl && !this.newThumbnail) {
      //   this.deleteImageRef();
      // }

      if (this.editMode && this.productKey) {
        this.currentProduct = this.db.object('/products/' + this.productKey);
        this.currentProduct.update(productObject);
        this.updateCategory(this.ogCategory, this.newCategory, this.productKey);
      } else {
        this.products.push(productObject).then((item) => {
          if (this.newCategory) {
            this.db.object('/products/' + item.key + '/entityKey').set(item.key);
            this.db.object('/categories/' + this.newCategory + '/products/' + item.key).set(Date.now().toString());
          }
        });
      }

      let snackBarRef = this.snackBar.open('Product saved', 'OK!', {
        duration: 3000
      });
    }

    this.validateFields(newTitle, newDescription, newPrice);
  }
开发者ID:mogeta,项目名称:firebase-cms,代码行数:46,代码来源:add-product.component.ts


注:本文中的angularfire2/database.AngularFireList类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。