How to trigger window resize event in Angular

前端 未结 1 1518
-上瘾入骨i
-上瘾入骨i 2021-02-18 17:41

I am using a Angular plugin on data table. The container of the data table is resizable, while through the doc I learned that the data table it self will resize when there is a

相关标签:
1条回答
  • 2021-02-18 17:49

    You can trigger window.resize event by

    window.dispatchEvent(new Event('resize'));
    

    And for listening to window.resize, use HostListener as below example:

    @HostListener('window:resize', ['$event'])
    sizeChange(event) {
      console.log('size changed.', event);
    }
    

    live demo

    0 讨论(0)
提交回复
热议问题