ngDoCheck

ngDoCheck method is called when Angular runs its change detection process so that directives have an opportunity to update any state that isn’t directly associated with an input property.

Dealing with collection-level data changes using ngdocheck

The second type of change occurs when the objects within the collection are added, removed, or replaced. Angular doesn’t detect this kind of change automatically, which means the iterating directive’s ngOnChanges method won’t be invoked.
Receiving notifications about collection-level changes is done by implementing the ngDoCheck method, which is called whenever a data change is detected in the application, regardless of where that change occurs or what kind of change it is. The ngDoCheck method allows a directive to respond to changes even when they are not automatically detected by Angular. Implementing the ngDoCheck method requires caution, however, because it represents a pitfall that can destroy the performance of a web application. To demonstrate the problem, the following example implements the ngDoCheck method so that the directive updates the content it displays when there is a change. Read More!

Comments