本文整理匯總了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
});
}
}
示例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
})
}
});
示例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
});
}
}
示例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})
}
})
示例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
});
}
}
示例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);
}
示例7: validateFields
validateFields(name: string) {
if (!name) {
let snackBarRef = this.snackBar.open('You must add a name for this category', 'OK!', {
duration: 3000
});
}
}
示例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
});
}
});
示例9: showMessage
protected showMessage(message: string, actionLabel?: string): void {
if (!isPresent(actionLabel)) {
actionLabel = 'OK';
}
this.snackBar.open(message, actionLabel, new MdSnackBarConfig());
}
示例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
});
// }
}
});