Expression ___ has changed after it was checked

后端 未结 17 1877
太阳男子
太阳男子 2020-11-22 05:53

Why is the component in this simple plunk

@Component({
  selector: \'my-app\',
  template: `
I\'m {{message}}
`, }) export class App {
17条回答
  •  长情又很酷
    2020-11-22 06:20

    I switched from AfterViewInit to AfterContentChecked and It worked for me.

    Here is the process

    1. Add dependency in your constructor:

      constructor (private cdr: ChangeDetectorRef) {}

    2. and call your login in implemented method code here:

       ngAfterContentChecked() {
           this.cdr.detectChanges();
        // call or add here your code
       }
      

提交回复
热议问题