5

In a non angular application we can respond to window resize events with the following:

  window.onresize = function(event) {
    console.log('changed');
  };

However we can't use this in angular applications since it's a bad practice to directly access the window object. How would we implement the above functionality in the 'angular' way?

Willem van der Veen
  • 27,075
  • 15
  • 160
  • 135

1 Answers1

5

For anyone who is interested:

  @HostListener('window:resize', ['$event']) onResize(event) {
     console.log(event.target.innerWidth;);
  }

Credits to: Angular window resize event

Willem van der Veen
  • 27,075
  • 15
  • 160
  • 135