I'm having a hard time understanding why ngFor isn't working with an array of observables.
export class DashboardComponent implements OnInit {
dwsubscriptions: Observable<Dwsubscription>[] = new Array();
ngOnInit() {
this.dwsubscriptions.push(
this.devicewiseService.getSubscription('Randomizer', '1', 3, 1, -1)
)
}
}
Then my html
<div *ngFor="let dwsubscription of dwsubscriptions | async">
<p>value: {{dwsubscription.params.data}}</p>
</div>
getSubscriptions is returning an observable
getSubscription(device: string, variable: string, type: number, count:number, length:number): Observable<Dwsubscription> {
I am getting the error
ERROR Error: InvalidPipeArgument: '[object Object]' for pipe 'AsyncPipe'
This works fine if I do async pipe on a single observable returned from getSubscription(). Why can't I push those observables to an array and then iterate through them in my template using ngFor?
dwsubscriptions
is not an Observable / async. It seems like you want to do*ngFor="let dwsubscription of dwsubscriptions"
and then{{ (dwsubscription | async).params.data
– Explosion Pills