1

I have worked for 2 years with AngularJS and ui-router.

For reasons of my project, I needed to trigger an event, which I detected when the DOM and the Binding had finished, but now I have a problem. I used $ stateChangeSuccess and then $ transitions and it works ...

In jQuery I used $ (document) .ready () ...

Now, I have migrated my project to Angular 5, and I do not know how to detect the full load of the DOM and Angular Binding. Is there an event or solution for my problem?

Thank you very much!

Sergio
  • 11
  • 2
  • There are few interface that could help you, I would recommend to read the angular life cycle https://angular.io/guide/lifecycle-hooks maybe onInit is the option for you. It depends on what are you looking for. Just make sure that your DOM is modify only by angular and not by an external jquery script. – Daniel C. Dec 20 '17 at 22:51

1 Answers1

0

You can access the document object by injecting it like this. See https://stackoverflow.com/a/37521339/8910524.

However, the angular way is to avoid touching the DOM imperatively, and instead write events, flags on templates using ngIf etc. So whatever your usecase, there probably is a different way to do it in angular.