How to write window resize event in Angular?

Forums AngularHow to write window resize event in Angular?
Staff asked 7 months ago

Answers (1)

Add Answer
monika gabani Marked As Accepted
Staff answered 7 months ago

In app.component.html file:

<div (window:resize)="onResize($event)"

app.component.ts file

height:number;
width:number;
onResize(event) {
 this.width = Math.round(event.target.innerWidth);
 this.height = Math.round(event.target.innerWidth);
}

Now,  you can get width & height of window when you resize it.

Subscribe

Select Categories