Angular 12 Detect Width and Height of Screen Tutorial - positronX.io

PHOTO EMBED

Fri Sep 17 2021 07:08:17 GMT+0000 (Coordinated Universal Time)

Saved by @alecsanderu #typescript

import { Component, HostListener } from '@angular/core';


@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.scss']
})

export class AppComponent {
  
  public getScreenWidth: any;
  public getScreenHeight: any;
  
  ngOnInit() {
      this.getScreenWidth = window.innerWidth;
      this.getScreenHeight = window.innerHeight;
  }
  
  @HostListener('window:resize', ['$event'])

  onWindowResize() {
    this.getScreenWidth = window.innerWidth;
    this.getScreenHeight = window.innerHeight;
  }
  
}
content_copyCOPY

https://www.positronx.io/angular-detect-width-and-height-of-screen-tutorial/