Simon Green
Simon Green

Reputation: 1161

Event when AngularJS finished changing DOM

I have some AngularJS code which sets up some scope fields very quickly, but then takes AngularJS and/or Chrome a long time to create and render the DOM. This is mainly due to a few ng-repeat bindings to long lists in the scope. The browser freezes for a couple of seconds whilst preparing and rendering the DOM.

I'd like to know when the browser has finished, so that I can display a loading sign whilst the browser is busy, and then display the resulting DOM once it has finished. What techniques are available for achieving this?

Upvotes: 0

Views: 315

Answers (1)

Berlin_Bro
Berlin_Bro

Reputation: 109

Angular is providing a great way to catch the moment your component is done loading. have a look at Lifecyle Hooks. They are built in ways to hook on these angular defined events and are super easy to use(see tutorial in the link).

In your case i would go with ngAfterViewInit() or ngAfterViewChecked().

Hope you find this usefull feel free to add questions.

Upvotes: 1

Related Questions