0

I'm building a single page application with Angular2.

Several of my component properties are provided by async service calls, and the service returning the data is slow. While waiting, the template shows in the browser with several {{variable}} incomplete evaluations.

How can I hook into Angular2's template processor so I am notified when all template expressions have been evaluated? I can show a spinner until that event fires, then remove the spinner.

This example comes close, but doesn't tie into the template processor: Show loading screen when navigating between routes in Angular 2

Thanks!

Community
  • 1
  • 1
TimH
  • 1,012
  • 1
  • 14
  • 24
  • Can you replicate your scenario in Plunker, with settimeout? – Madhu Ranjan Mar 02 '17 at 19:18
  • I tried a simple settimeout example in Plunker, but it didn't suffer from the same problem. I'll try to set up a Plunker that reproduces the issue. – TimH Mar 02 '17 at 19:34
  • Seems really low-level to hook into the template processor. Besides the delay you describe is not due to the template processor but to the fact the data hasn't yet been returned by the backend (once Angular has the data, it will generate the template almost immediately). If I were you I'd hook into HTTP requests instead and display the spinner as long as you have a pending request. – AngularChef Mar 03 '17 at 08:49

0 Answers0