Tooltip _unregisterListenersFn error
See original GitHub issueBug description:
I’m using NgbTooltip with a variable translated string (with NgxTranslate but according to my tests it has no impact on the error) :
<button class="btn btn-lg btn-hidden"
placement="top"
ngbTooltip="{{ bookmarkId ? 'UNFOLLOW' : 'FOLLOW' | translate }}"
(click)="toggle()"
*ngIf="!bookmarkId">
<i class="icon" [ngClass]="{'icon-star text-color-yellow': bookmarkId, 'icon-star_border': !bookmarkId}"></i>
</button>
Which throw this error :
ERROR TypeError: this._unregisterListenersFn is not a function at NgbTooltip.ngOnDestroy (tooltip.js:141) at callProviderLifecycles (core.js:12697) at callElementProvidersLifecycles (core.js:12658) at callLifecycleHooksChildrenFirst (core.js:12641) at destroyView (core.js:14007) at callViewAction (core.js:14158) at execComponentViewsAction (core.js:14070) at destroyView (core.js:14006) at callWithDebugContext (core.js:15041) at Object.debugDestroyView [as destroyView] (core.js:14592)
Thanks for your help !
Version of Angular, ng-bootstrap, and Bootstrap:
Angular CLI: 1.6.4 Node: 8.9.4 OS: darwin x64 Angular: 5.2.0 @angular/cli: 1.6.4 @angular-devkit/build-optimizer: 0.0.37 @angular-devkit/core: 0.0.24 @angular-devkit/schematics: 0.0.45 @ngtools/json-schema: 1.1.0 @ngtools/webpack: 1.9.4 @schematics/angular: 0.1.12 typescript: 2.4.2
ng-bootstrap: 1.0.0-beta.6
Bootstrap: 4.0.0-beta.2
Issue Analytics
- State:
- Created 6 years ago
- Comments:9 (5 by maintainers)
Top GitHub Comments
@pkozlowski-opensource I just ran into the same issue. My scenario is that I attach a custom structural directive to an element that also has the tooltip directive on it. The structural directive has multiple parameters and evaluates whether to create or destroy the view when each parameter is set. This can cause the view to be created and destroyed quickly. It is quick enough that
ngOnInit
has not had time to run on the tooltip directive beforengOnDestroy
has run. So_unregisterListenersFn
is undefined and I get the errorthis._unregisterListenersFn is not a function
. Just wraping the_unregisterListenersFn
in a null check should do the trick.Here is a working (or rather not working) example: https://stackblitz.com/edit/acl-directive
@pkozlowski-opensource created here: #2199