ExpressionChangedAfterItHasBeenCheckedError Explained

前端 未结 26 1874
慢半拍i
慢半拍i 2020-11-22 14:46

Please explain to me why I keep getting this error: ExpressionChangedAfterItHasBeenCheckedError: Expression has changed after it was checked.

Obviously,

26条回答
  •  迷失自我
    2020-11-22 15:47

    I hope this helps someone coming here: We make service calls in ngOnInit in the following manner and use a variable displayMain to control the Mounting of the elements to the DOM.

    component.ts

      displayMain: boolean;
      ngOnInit() {
        this.displayMain = false;
        // Service Calls go here
        // Service Call 1
        // Service Call 2
        // ...
        this.displayMain = true;
      }
    

    and component.html

提交回复
热议问题