I have the following markup in my HTML. It works as supposed to and performs according to the expectations.
<ng-container *ngIf="stuff$ | async as data">
<div *ngFor="let element of data">{{element.name}}</div>
</ng-container>
I started to tamper with it to see what I can brake/improve so, assuming that the as data only assigns a variable name to the resulting outcome of subscription (due to async pipe), I hoped that I can reuse data$ directly, without going about the extra variable. So I changed to this.
<ng-container *ngIf="stuff$ | async">
<div *ngFor="let element of stuff$">{{element.name}}</div>
</ng-container>
This failed miserably, producing the error below.
ERROR Error: Cannot find a differ supporting object '[object Object]' of type 'object'. NgFor only supports binding to Iterables such as Arrays.
While I understand the sense of the error, I don't see where it's coming from. The service that I subscribe to returns an observable of an array. Is the as'ing of the property being async'ed mandatory? I'm sure there's a subtle, little thing I missed when I was reading up on the asynchronous pipe but I'm failing to see it.
stuff$: Observable<Thing[]>;
ngOnInit() { ...
this.stuff$ = this.stuffy.getStuff();
}