rxjs - Accessing result of async pipe in template from component code in Angular 2 -


in angular 2 have component template.

in component typescript code create reactive extensions observable (items$) , use in ngfor-directive in template async-pipe.

this way not have worry subscribing , unsubscribing myself.

<div *ngfor="let item of items$ | async"></div> ... </div> 

now component code access list of items, without subscribing it. there way template hand copy of or reference items list?

since angular 4+ can use special syntax as (works *ngif well):

<div *ngfor="let item of items$ | async items"></div>   {{ items.length }} ... </div> 

see example here https://angular.io/api/common/ngforof


Comments

Popular posts from this blog

php - Embed BBCode within itself not working -

three.js - how to load gltf in three JS -

sql server - T-SQL: Access DB objects in same schema without qualifying? -