How to trigger window resize event in Angular

前端 未结 1 557
礼貌的吻别
礼貌的吻别 2021-02-18 17:42

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 18:06

    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)
提交回复
热议问题