How to write window resize event in Angular?

Forums AngularHow to write window resize event in Angular?
Staff asked 3 years ago

Answers (1)

Add Answer
monika gabani Marked As Accepted
Staff answered 3 years 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