How to trigger window resize event in Angular

前端 未结 1 556
礼貌的吻别
礼貌的吻别 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)
提交回复
热议问题