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


TypeScript MdSnackBar.open方法代碼示例

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


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

示例1: addAdmin

  addAdmin(newEmail: string, newRole: string) {
    if (newEmail && newRole) {

      this.db.object('/admins/' + this.globalService.hashCode(newEmail)).update({
        email: newEmail,
        role: newRole
      });

      this.newEmail = null;
      this.newRole = null;

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

    } else if (!newEmail) {
      let snackBarRef = this.snackBar.open('You must add an email for the user', 'OK!', {
        duration: 3000
      });
    } else if (!newRole) {
      let snackBarRef = this.snackBar.open('You must add a role for the user', 'OK!', {
        duration: 3000
      });
    }
  }
開發者ID:mogeta,項目名稱:firebase-cms,代碼行數:25,代碼來源:add-admin.component.ts

示例2:

 val => {
     if(val.created === true || val.result === 'updated') {
         this.snackBar.open('query saved.', '', {
             duration: 2000
         })
     }else{
         this.snackBar.open('error: query not saved.', '', {
             duration: 2000
         })
     }
 });
開發者ID:yeg-relief,項目名稱:screenerClient,代碼行數:11,代碼來源:query-edit-v3.component.ts

示例3: validateFields

 validateFields(title, description, price) {
   if (!title) {
     let snackBarRef = this.snackBar.open('You must add a title for this product', 'OK!', {
       duration: 3000
     });
   } else if (!description) {
     let snackBarRef = this.snackBar.open('You must add a description to the product', 'OK!', {
       duration: 3000
     });
   } else if (!price) {
     let snackBarRef = this.snackBar.open('You must add a price to the product', 'OK!', {
       duration: 3000
     });
   }
 }
開發者ID:mogeta,項目名稱:firebase-cms,代碼行數:15,代碼來源:add-product.component.ts

示例4: if

 .subscribe(val => {                
     if (val.status === true){
         this.cacheQuery(this.searchForm.controls.searchitem.value)
         let adj:string = val.content.length <= 1 ? "result" : "results";
         let msg:string = `${val.content.length} ${adj} found`
         this.snackbar.open(msg,"View")
         this.snackbar._openedSnackBarRef.onAction().subscribe(() =>{
             this.resultDialog.open(SearchResultDialogComponent,{
                 height:'35rem',width:'65rem',data:val.content.content
             })                        
         })
     }else if (val.status === false){
         this.snackbar.open("Nothing found","Close",{duration:1000})                    
     }                
 })
開發者ID:daviddexter,項目名稱:wajibu,代碼行數:15,代碼來源:top.box.component.ts

示例5: validateFields

 validateFields(url: string, title: string, body: string) {
   if (!url) {
     let snackBarRef = this.snackBar.open('You must add a URL for this page', 'OK!', {
       duration: 3000
     });
   } else if (!title) {
     let snackBarRef = this.snackBar.open('You must add a title for this page', 'OK!', {
       duration: 3000
     });
   } else if (!body) {
     let snackBarRef = this.snackBar.open('You must add content to the page', 'OK!', {
       duration: 3000
     });
   }
 }
開發者ID:mogeta,項目名稱:firebase-cms,代碼行數:15,代碼來源:add-page.component.ts

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

示例7: validateFields

 validateFields(name: string) {
   if (!name) {
     let snackBarRef = this.snackBar.open('You must add a name for this category', 'OK!', {
       duration: 3000
     });
   }
 }
開發者ID:mogeta,項目名稱:firebase-cms,代碼行數:7,代碼來源:add-product-category.component.ts

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

示例9: showMessage

    protected showMessage(message: string, actionLabel?: string): void {
        if (!isPresent(actionLabel)) {
            actionLabel = 'OK';
        }

        this.snackBar.open(message, actionLabel, new MdSnackBarConfig());
    }
開發者ID:Invis1ble,項目名稱:assistant-client,代碼行數:7,代碼來源:abstract-component.ts

示例10:

    dialogRef.afterClosed().subscribe(result => {
      this.selectedOption = result;
      if (this.selectedOption === 'delete') {
        this.db.object('/products/' + product.key).remove();
        if (product.category) {
          this.db.object('/categories/' + product.payload.val().category + '/products/' + product.key).remove();
        }

        // if (product.thumbnail) {
        //   let storage = firebase.storage();
        //   let imageRef = storage.refFromURL(product.thumbnail);
        //   let me = this;
        //   imageRef.delete().then(function() {
        //     let snackBarRef = me.snackBar.open('Product deleted', 'OK!', {
        //       duration: 3000
        //     });
        //   }).catch(function(error) {
        //     console.log('error', error);
        //   });
        // } else {
          let snackBarRef = this.snackBar.open('Product deleted', 'OK!', {
            duration: 3000
          });
        // }
      }
    });
開發者ID:mogeta,項目名稱:firebase-cms,代碼行數:26,代碼來源:admin-products.component.ts


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