Monday, 10 April 2017

How to check when angular2 component is fully loaded? (NodeJS + Angular2)

I have a angular2 component, that should display weather chart. It has an API call inside of it, that pulls the data from the server and displays it. However, it takes a couple of seconds to load the data fully. Is there a way, callback, or something implemented in angular2, that will alert me when everything in component was fully loaded? I tried using things like:

ngAfterViewChecked()
ngAfterContentInit()
...

But none of them seems to work. However, I have managed to do it without angular (in service that creates the weather api call, I just added the code when everything finishes and it works properly. But, I want to find the best way to do it, preferably something implemented in angular2. Something like this for example.

ngComponentFullyLoaded()

that will fire when every little detail is loaded inside of the component.

If someone have any ideas how to do it, please share with me.

Best regards, Nikola



via Никола Пејић

No comments:

Post a Comment