Bug description:
If an element with the tooltip directive on it is quickly created and destroyed by a structural directive then it causes the following error:
AppComponent.html:3 ERROR TypeError: this._unregisterListenersFn is not a function
at NgbTooltip.ngOnDestroy (tooltip.js:152)
at callProviderLifecycles (provider.js:588)
at callElementProvidersLifecycles (provider.js:556)
at callLifecycleHooksChildrenFirst (provider.js:540)
at destroyView (view.js:600)
at callWithDebugContext (services.js:843)
at Object.debugDestroyView [as destroyView] (services.js:382)
_unregisterListenersFn
is initialized in ngOnInit
so it appears that it is not being invoked before ngOnDestroy
.
Link to minimally-working plunker that reproduces the issue:
https://stackblitz.com/edit/acl-directive
Version of Angular, ng-bootstrap, and Bootstrap:
Angular: 5.0.0
ng-bootstrap: 1.0.0
Bootstrap: N/A
@pkozlowski-opensource Agreed, I realized that it wasn’t optimal to create an destroy it so quickly but it illustrated the point so I left it alone. I’ve seen it come up with weird routing scenarios too and apparently someone found a way to do it with
ngIf
. I think that most scenarios where this is an issue can and should be avoided but it is still good to guard against it. As far as it being “brutal”ngIf
is doing the same thing (https://github.com/angular/angular/blob/master/packages/common/src/directives/ng_if.ts) and that is the behavior that I wanted to mimic. I want to destroy all views in the container.Thanks for taking the time to look into the issue and the feedback!