Angular 2 Error: attempt to use the destroyed view: detectChanges Error: attempt to use the destroyed view: detectChanges in ViewDestroyedError

I am using ng2-toastr and getting the following 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.

+5
source share
1 answer

add this:

 ngOnDestroy() { this.helper.toastr.dispose();} 

and change node_modules/ng2-toastr/bundle/toast-manager.js :

 ToastsManager.prototype.dispose = function () { var _this = this; if (_this.container) { _this.container.destroy(); _this.container = null; } }; 
-2
source

Source: https://habr.com/ru/post/1264513/


All Articles