0

I implemented a loading animation that shows a spinner reacting on Angular's router events (NavigationStart, NavigationEnd) which works good. But the first component that is initially called and which may have a resolver that fetchs data from an API sometimes need more than 2s for loading. But I don't get any router events, so the loading animation does not show. Also when the component is resolved there are no events on router.. any ideas how to implement a loading indicator for the first called component?

Check this flow:

  1. AppComponent is bootstrapped

  2. After AppComponent is loaded the loading animation from index.html is gone (that's good)

  3. Routing determines which component to load.

  4. Resolver for that component starts to fetch data from API.

5. No loading animation is shown because router does not emit any events at this time.

  1. Resolver is done and component is loaded.

  2. Switch component through routing.

8. Router emits event (loading animation is shown)

Note: I also got a loading animation in my index.html of course but that's not what I am looking for...

1 Answers1

0

The following was the fix:

The router-outlet has an Output (activate)="activate($event)" which I could use to hide the extra loading info.