本文整理匯總了TypeScript中app/services/global.service.GlobalService.hashCode方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript service.GlobalService.hashCode方法的具體用法?TypeScript service.GlobalService.hashCode怎麽用?TypeScript service.GlobalService.hashCode使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類app/services/global.service.GlobalService
的用法示例。
在下文中一共展示了service.GlobalService.hashCode方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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:
this.user.subscribe(currentUser => {
if (!currentUser) {
this.router.navigateByUrl('login');
} else {
this.db.object('/admins/' + this.globalService.hashCode(currentUser.email)).valueChanges().subscribe((a:any) => {
if (a && a.email) {
this.globalService.admin.next(currentUser);
this.db.object('/admins/' + currentUser.uid).valueChanges().subscribe((a:any) => {
this.globalService.admin.next(a);
this.currentAdmin.role = a.role;
});
} else {
this.router.navigateByUrl('');
let snackBarRef = this.snackBar.open('You are not an authorized administrator', 'OK!', {
duration: 3000
});
}
}, (err) => {
console.log('Permission Error', err);
this.router.navigateByUrl('');
let snackBarRef = this.snackBar.open('You are not an authorized administrator', 'OK!', {
duration: 3000
});
});
}
});
示例3: confirm
confirm() {
this.submitNewCharge();
let newKey = Math.abs(this.globalService.hashCode(this.order.date) + this.globalService.hashCode(this.order.shipping.email));
this.db.list('/orders').push(this.order).then((item) => {
this.globalService.cart.next(null);
this.globalService.order.next(null);
this.localCart.clearAll();
if (this.user) {
this.db.object('/users/' + this.user.uid + '/cart').remove();
this.db.object('/users/' + this.user.uid + '/orders/' + item.key).set(Date.now().toString());
}
this.router.navigateByUrl('checkout/confirmation');
});
}