Reputation: 741
Is it possible for the parent get notified that all the child views have been rendered?
I know that we have lifecycle hooks like ngAfterViewChecked()
but is it fired after child views are rendered?
Upvotes: 1
Views: 4195
Reputation: 4512
Documentation states (about ngAfterViewChecked
):
Respond after Angular checks the component's views and child views. Called after the
ngAfterViewInit
and every subsequentngAfterContentChecked()
. A component-only hook.
So, yeah, child views will trigger this callback. The problem is that you can't tell which view was updated. If you want to know about specific views being updated I suggest to wrap them in Components
, override ngAfterViewChecked
inside each one and use EventEmitter
(as Output
) to notify parent Component
. In case you want to listen for initial render, override ngAfterContentChecked
.
Update #1:
If you care only about the first render and don't have to differentiate between views it's enough to override ngAfterViewInit
:
Respond after Angular initializes the component's views and child views. Called once after the first
ngAfterContentChecked()
. A component-only hook.
Upvotes: 3