I am writing an Angular2 component that should dynamically change its contents when resized. I am using the experimental Renderer in @ angular / core (v2.1.0) and can connect a click listener with the following:
this.rollupListener = this.renderer.listen(this.rollUp, 'click', (event) => { ... });
But, unfortunately, I cannot do the same for the resize event - both "resize" and "onresize" do not work:
this.resizeListener = this.renderer.listen(this.container, 'resize', (event) => { // this never fires :( });
I can select browser resize events using the following:
@HostListener('window:resize', ['$event.target']) onResize() { ... }
But, unfortunately, not all resizing components in my application are due to resizing the browser.
Basically, I'm looking for a jQuery equivalent:
$(this.container).resize(() => { ... });
source share