Monday, September 25, 2017

How do I get the width of an ElementRef in Angular 4 at the TypeScript side?

Assuming whatever is an ElementRef...

getTheWidthOfWhatever():number{
   let nativeElement:HTMLElement = this.whatever.nativeElement;
   let wideness:number = nativeElement.offsetWidth;
   return wideness;
}

 
 

There is also an .offsetHeight too.

No comments:

Post a Comment