Reputation: 3258
What is the best way to capture a completed redraw/render event of an angular component? I want this to occur AFTER every time the component has re-rendered due to some input property changing.
As far as I can see, ngOnChanges fires when any input property changes, but it fires before any subsequent component redraws occurs.
Upvotes: 5
Views: 12023
Reputation: 13993
You would have to use the ngAfterViewChecked() lifecycle hook:
Respond after Angular checks the component's views and child views / the view that a directive is in.
Called after the ngAfterViewInit() and every subsequent ngAfterContentChecked().
However, this may cause performance issues:
Notice that Angular frequently calls AfterViewChecked(), often when there are no changes of interest. Write lean hook methods to avoid performance problems.
Upvotes: 5