我正在尝试在加载任何页面时使用角度烤面包机。 例如 - 我有两页客户添加和客户列表,我的要求是当我添加任何新客户时在客户列表页面上显示烤面包机。
这是我的代码:saveCustomer中的代码回调
this.$state.go('app.Customers', { Msg: d.Message });
客户列表页面中的代码: HTML:
<toaster-container toaster-options="{'position-class': 'toast-top-right', 'close-button':true}"></toaster-container>
JS:
static $inject=['toaster']
constructor( private toaster: any){
if (this.$stateParams.Msg !== null)
this.msgToClient = this.$stateParams.Msg;
this.toaster.pop('success', 'Success', this.msgToClient);
}
我没有在客户列表页面上看到此消息。 但我可以在(点击)等事件中看到烤箱信息。我尝试了很多方法,但没有运气。
答案 0 :(得分:2)
我已经遇到过这个问题。我知道它并不优雅,但我这样解决了:
setTimeout(function(){
toaster.pop('success', 'Success', 'Page Load');
$scope.$apply();
}, 100);