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


TypeScript AngularFireObject.update方法代碼示例

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


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

示例1: onChange

 onChange(e: any, key: string) {
   this.page = this.db.object('/pages/' + key);
   if (e.checked) {
     this.page.update({published: true});
   } else {
     this.page.update({published: false});
   }
 }
開發者ID:mogeta,項目名稱:firebase-cms,代碼行數:8,代碼來源:admin-pages.component.ts

示例2: saveTheme

  saveTheme(newSiteName: string) {
    this.theme.update({
      siteName: newSiteName
    });

    let snackBarRef = this.snackBar.open('Theme updated', 'OK!', {
      duration: 3000
    });
  }
開發者ID:mogeta,項目名稱:firebase-cms,代碼行數:9,代碼來源:admin-theme.component.ts

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

示例4: addPost

  addPost(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 postObject = {
        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,
        entityKey: this.editMode && this.postKey ? this.postKey : null
      };

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

      if (this.editMode && this.postKey) {
        this.currentPost = this.db.object('/posts/' + this.postKey);
        this.currentPost.update(postObject);
      } else {
          this.posts.push(postObject).then((item) => {
            this.db.object('/posts/' + item.key + '/entityKey').set(item.key);
          });
      }

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

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


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