Emanuel Weinsjö Emanuel Weinsjö - 2 months ago 28
TypeScript Question

Angular 2 - How can I block GUI rendering while waiting on http request to finish

It's possible to wait rendering the GUI/components and show it when the task has finish.

Like


  1. Request the website in brwoser.

  2. Start a task loading some data from server.

  3. When task has finish tell angular2 to continue loading in all components.

  4. Rendering finish.






</head>
<body>
<div *ngIf="UserData">
<app>Laddar...</app>
</div>
<div *ngIf="!UserData">
Laddar...
</div>
</body>
</html>


So blocking top component, all componets in the moudle will be blocked?

Answer
<div *ngIf="data">
  {{content}}
</div>
http.get(...).subscribe(val => this.data = val);