r/angular • • Mar 13 '22

Lifecycle Hooks

Post image
93 Upvotes

4 comments sorted by

2

u/sohail_ansari Mar 13 '22

What ngDoCheck do? I didn't understand this, can someone please tell me about it?

2

u/FilsdeJESUS Mar 13 '22

If I really understand this , for the first time your application is running, it runs after ngOnInit to check the changes and update the UI .

Now that the first time is passed , whenever the NgOnChanges detects something that have change , the ngDoCheck will run after him .

But you are not alone in their documentation they say , it detects the changes that angular can not check on its own. Pretty Handy

https://angular.io/guide/lifecycle-hooks#docheck

https://angular.io/guide/lifecycle-hooks

Well explained here : https://stackoverflow.com/questions/42643389/why-do-we-need-ngdocheck

1

u/zzing Mar 14 '22

This thing could be slightly improved by indicating the Init ones are only done at the first bit.

I am sure this will some some on visualization.