Expression ___ has changed after it was checked

后端 未结 17 2074
太阳男子
太阳男子 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条回答
  •  萌比男神i
    2020-11-22 06:25

    It throw an error because your code get updated when ngAfterViewInit() is called. Mean your initial value got changed when ngAfterViewInit take place, If you call that in ngAfterContentInit() then it will not throw an error.

    ngAfterContentInit() {
        this.updateMessage();
    }
    

提交回复
热议问题