[BUG] MdlPopover firing TypeError on ngOnDestroy()
Hello, I'm using MdlSelect in my project (which includes MdlPopover) and since today I am facing an error whenever I swap from a view with an MdlSelect component to another view, which fires its ngOnDestroy() method causing the next error:
ERROR Error: Uncaught (in promise): TypeError: Failed to execute 'removeEventListener' on 'EventTarget': 2 arguments required, but only 1 present. TypeError: Failed to execute 'removeEventListener' on 'EventTarget': 2 arguments required, but only 1 present. at HTMLElement.proto.(anonymous function) [as removeEventListener] (http://localhost:4200/polyfills.bundle.js:3858:46) at MdlPopoverComponent.ngOnDestroy (http://localhost:4200/vendor.bundle.js:57832:39) at callProviderLifecycles (http://localhost:4200/vendor.bundle.js:11657:18) at callElementProvidersLifecycles (http://localhost:4200/vendor.bundle.js:11626:13) .......
This error referes to the next method in node_modules//popover.js
MdlPopoverComponent.prototype.ngOnDestroy = function () {
this.elementRef.nativeElement.removeEventListener('hide'); };
}
The error itself claims that removeEventListener needs 2 arguments instead of one, so as suggested by @tonu42 we can change it to:
MdlPopoverComponent.prototype.ngOnDestroy = function () {
this.elementRef.nativeElement.removeEventListener(this,'hide');
};
and now it works perfectly, without any error.
Thank you
UPDATED on 17/7 highlighting code text and adding possible solution
Same issue here
Same here too
i guess it's this issue: https://github.com/angular/zone.js/pull/834 - workaround: pin zone.js to 0.8.12
Fixing zone.js to 0.8.12 made it work again. Hopefully it is fixed for 0.8.14.
Thank you for the workaround @mseemann
Alternatively, editing popover.js line 34 will fix this problem.
Broken
MdlPopoverComponent.prototype.ngOnDestroy = function() { this.elementRef.nativeElement.removeEventListener('hide'); };
Working
MdlPopoverComponent.prototype.ngOnDestroy = function() { this.elementRef.nativeElement.removeEventListener(this,'hide'); };
Could we have an update on MdlPopover with this change? @mseemann
Same here
Our temporary fix: In main.ts
@import { MdlPopoverComponent } from '@angular-mdl/popover';
MdlPopoverComponent.prototype.ngOnDestroy = function () {
this.elementRef.nativeElement.removeEventListener(this, 'hide');
};
-> @angular-mdl/popover:0.6.4
btw. the signature for removeEventListener is:
removeEventListener(type: string, listener?: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void;
@mseemann @angular-mdl/popover:0.6.4 looks fixed, but looks like old version of popover is embeded in index.umd.js of select see:

Quick fix would be to update select. Is this correct that its embeded there?
fix: @angular-mdl/select:0.10.5
@tb Thx for taking a look into it! you are right. the popover stuff shouldn't be in the umd.js file. need to change the build configuration and check that it still all works.