【发布时间】:2018-08-16 14:10:06
【问题描述】:
我正在使用 angularfire2 并进行推送调用来存储对象。如下所示:
点击处理程序
assignCode(){
this.ddlSvc.assignCoupon(this.selItem.key, coupon).then(
(resp) => {
console.log("user created with:" + resp)
const alert = this.core.createAlert('Confirmation', 'Coupon Assgined to customer!')
alert.present()
}
)
}
角度服务调用 firebase
assignCoupon(key:string, coupon:Coupon){
return this.db.list('/users/' + key + '/coupons').push(coupon)
}
当调用客户端用户具有推送到该节点所需的权限时,它可以正常工作。但是,我们正在测试调用客户端没有权限的情况。目前,当我们触发这个案例时,我们会以一种非常丑陋的方式在 UI 上得到所有错误,而不是一个很好的弹出窗口,因为我们没有处理它。那么,我们如何处理错误部分呢?因为它是一个 thenable 引用,所以点击处理函数没有 . “.catch”来处理。
【问题讨论】:
标签: typescript firebase-realtime-database angularfire2