I\'m learning Angular 2 and I\'ve been working with static arrays, and now I\'m trying to learn more about reading remote data.
My app.component.ts
:
Plunker
To loop over Array:
<li *ngFor="let doc of docs">{{doc.id}}</li>
To loop over Object Properties:
You will have to generate an Array
of the object properties
generateArray(obj){
return Object.keys(obj).map((key)=>{ return obj[key]});
}
and use it like
<li *ngFor="let doc of docs">
<span *ngFor="let v of generateArray(doc)"> {{v}} </span>
</li>
Or you can use as Pipe.