0

Let's say app component has inside a component that has inside b component and a and b components are detached and every component has a button. Why then each time when I click any button I get this in the console? I thought that ngAfterContentChecked and ngAfterViewChecked should not be called in a component because it is detached? https://stackblitz.com/edit/angular-afkaxc

ngDoCheck App
ngAfterContentChecked App
ngDoCheck A
ngAfterContentChecked A
change detection beginning app
ngAfterViewChecked A
ngAfterViewChecked App
change detection beginning app
manfromstoman
  • 23
  • 1
  • 4
  • Events still trigger CD even if they occur in detached views. Take a look at [this article](https://blog.angular-university.io/onpush-change-detection-how-it-works/), "OnPush change detection and event handlers" section – Shlang Apr 02 '20 at 21:50
  • I know but why ngAfterContentChecked and ngAfterViewChecked are called in the detached component (a) but change detection in (a) component has not occurred (the view for a comppnent has not be re-rendered)? – manfromstoman Apr 02 '20 at 23:15
  • Does this answer your question? [Angular ngDoCheck() gets called even with ChangeDetectionStrategy.OnPush](https://stackoverflow.com/questions/45521588/angular-ngdocheck-gets-called-even-with-changedetectionstrategy-onpush) – Shlang Apr 03 '20 at 07:42

0 Answers0