Folky.H
Folky.H

Reputation: 1204

Angular 2 - Populate JSON array to the view only after x seconds

I generate a JSON array (manually and based on random numbers) on the controller level. However, I want to show the elements of that JSON array after 15 seconds, on that 15 seconds on the view I want to display pending status then after the 15 seconds pending will be replaced by the results of the JSON array.

Any idea on how can I do that?

Upvotes: 0

Views: 57

Answers (1)

user663031
user663031

Reputation:

Starting with @jonrsharpe's comment,

/* component */
this.later = Observable.of(data).delay(15000);

<!-- template -->
<div *ngIf="later | async as data; else wait">{{data}}</div>
<div #wait>Wait...</div>

This will require Angular 4.

Upvotes: 2

Related Questions