Bind to size of element (div)

后端 未结 1 2061
感情败类
感情败类 2021-02-05 17:11

I have a component with Width and Height properties. How can I bind component\'s view height and width to these properties?

I need them to be updated whenever component

1条回答
  •  Happy的楠姐
    2021-02-05 17:39

    Use (window:resize)="onResize($event)" to listen to global events. You can use window, document or body as targets. See this plunk

    @Component({
      selector: 'my-app',
      template: `
        
    ` }) export class App { width = 100; height = 100; onResize(event) { this.width += 100; this.height += 100; } }

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