xxxxxxxxxx
import { Component, OnInit } from '@angular/core';
@Component({ })
export class MyComponent implements OnInit {
screenWidth: number;
ngOnInit() {
this.getScreenWidth();
}
getScreenWidth() {
this.screenWidth = window.innerWidth;
}
}
xxxxxxxxxx
@HostListener('window:resize', ['$event'])
onResize(event?) {
this.screenHeight = window.innerHeight;
this.screenWidth = window.innerWidth;
}
//https://stackoverflow.com/questions/39888768/how-to-get-height-and-width-of-device-display-in-angular2-using-typescript