ngIf - Expression has changed after it was checked

后端 未结 6 1511
误落风尘
误落风尘 2021-02-01 12:37

I have a simple scenario, but just can\'t get it working!

In my view I display some text in a box with limited height.

The text is being fetched from the server,

6条回答
  •  暖寄归人
    2021-02-01 13:24

    To overcome this issue you can move the variable that changes *ngIf state, from ngAfterViewInit to ngOnInit or constructor.

    As @tiep-phan told, another way is that pass ChangeDetectorRef to constructor and call detectChanges() whenever you change the state of *ngIf.

提交回复
热议问题