asynchronous - Angular *ngFor bound to observable with async pipe - whats happening? -
i have started angular4 , have came against conceptual problem. async
pipe (used in combination *ngfor
in case) meant subscribe observable , away manual subscriptions. looking @ examples on web:
case 1: binding observable contains single items such observable<user>
case 2: binding observable contains arrays of items such observable<user[]>
case 3: variations of 1 , 2 subject, promise or behavioursubject
(example of case 1 single item: http://briantroncone.com/?p=623)
(example of case 2 array: http://www.concretepage.com/angular-2/angular-2-async-pipe-example)
conceptually ngfor
iterates on enumerable , i'm assuming enumerable item emitted observable
, not observable itself.
so *ngfor="let user of users" going work on observable<user[]>
, not observable<user>
?
the *ngfor
triggered each item arrives observable?
if case how can bind observable
of item
, not item[]
, how ngfor iterate on item when not enumerable? thanks.
*ngfor="let user of users" going work on
observable<user[]>
, notobservable<user>
?
yes, ngfor
directive create template once per item iterable. see description of ngfor. iterable
not object
.
the *ngfor triggered each item arrives observable?
no, while using observable, ngfor
work when observable emit value(entire iterable not pre item of it).
how ngfor iterate on item when not enumerable?
since ngfor
supports iterable
, can create pipe converting object array
object.values
or object.keys
ngfor
can iterate.
Comments
Post a Comment