Updating value in parent component from child one causes ExpressionChangedAfterItHasBeenCheckedError in Angular
问题 I have two component: ParentComponent > ChildComponent and a service, e.g. TitleService . ParentComponent looks like this: export class ParentComponent implements OnInit, OnDestroy { title: string; private titleSubscription: Subscription; constructor (private titleService: TitleService) { } ngOnInit (): void { // Watching for title change. this.titleSubscription = this.titleService.onTitleChange() .subscribe(title => this.title = title) ; } ngOnDestroy (): void { if (this.titleSubscription) {