Reset error in Angular2 ngOnInit not working as expected

When I have an error inside ngOnInit()

, this error seems to bubble up with an error TypeError: this._unregisterListenersFn is not a function

.

Example:

constructor() {
   throw Error('error in constructor');
}

      

gives the expected result in a console window. but in ngOnInit ():

ngOnInit() {
   throw Error('error in ngOnInit')
}

      

gives the first error in ngOnInit as expected, but also

TypeError: this._unregisterListenersFn is not a function

      

I'm trying to handle all errors with a custom error handler, but when an error happens inside ngOnInit (), I only get the most recent error, not the error causing the errors in the first place.

Edit-follow-up: I think I found the root cause in NgbPopover. The error message shown in Chrome Developer Tools:

TypeError: this._unregisterListenersFn is not a function
    at NgbPopover.webpackJsonp.../../../../@ng-bootstrap/ng-bootstrap/popover/popover.js.NgbPopover.ngOnDestroy (popover.js:128)

      

+3


source to share





All Articles