Angular 2 错误:尝试使用被破坏的视图:detectChanges 错误:尝试使用被破坏的视图:在 ViewDestroyedError 中检测更改 [英] Angular 2 Error: Attempt to use a destroyed view: detectChanges Error: Attempt to use a destroyed view: detectChanges at ViewDestroyedError
本文介绍了Angular 2 错误:尝试使用被破坏的视图:detectChanges 错误:尝试使用被破坏的视图:在 ViewDestroyedError 中检测更改的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用 ng2-toastr 并收到以下错误
I'm using ng2-toastr and getting the below error
https://www.npmjs.com/package/ng2-toastr
Attempt to use a destroyed view: detectChanges Error: Attempt to use a destroyed view: detectChanges at ViewDestroyedError
我在按钮点击事件中有这个.
I have this in a button click event.
推荐答案
添加:
ngOnDestroy() {
this.helper.toastr.dispose();}
和node_modules/ng2-toastr/bundle/toast-manager.js
中的变化:
ToastsManager.prototype.dispose = function () {
var _this = this;
if (_this.container) {
_this.container.destroy();
_this.container = null;
}
};
这篇关于Angular 2 错误:尝试使用被破坏的视图:detectChanges 错误:尝试使用被破坏的视图:在 ViewDestroyedError 中检测更改的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文