Angular2 - Expression has changed after it was checked - Binding to div width with resize events

前端 未结 4 676
清歌不尽
清歌不尽 2020-12-01 02:10

I have done some reading and investigation on this error, but not sure what the correct answer is for my situation. I understand that in dev mode, change detection runs twic

4条回答
  •  生来不讨喜
    2020-12-01 02:37

    Other way that i used to resolve this:

    import { Component, ChangeDetectorRef } from '@angular/core';
    
    
    @Component({
      selector: 'your-seelctor',
      template: 'your-template',
    })
    
    export class YourComponent{
    
      constructor(public cdRef:ChangeDetectorRef) { }
    
      ngAfterViewInit() {
        this.cdRef.detectChanges();
      }
    }
    

提交回复
热议问题