Quantcast
Viewing latest article 13
Browse Latest Browse All 20

Answer by PRAISER for Angular window resize event

I wrote this lib to find once component boundary size change (resize) in Angular, may this help other people. You may put it on the root component, will do the same thing as window resize.

Step 1: Import the module

import { BoundSensorModule } from 'angular-bound-sensor';@NgModule({  (...)  imports: [    BoundSensorModule,  ],})export class AppModule { }

Step 2: Add the directive like below

<simple-component boundSensor></simple-component>

Step 3: Receive the boundary size details

import { HostListener } from '@angular/core';@Component({  selector: 'simple-component'  (...)})class SimpleComponent {  @HostListener('resize', ['$event'])  onResize(event) {    console.log(event.detail);  }}

Viewing latest article 13
Browse Latest Browse All 20

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>