I want to use async pipe on a simple observable returned by from:
in component.ts
myData$ = from([
{ name: "Los Angeles", population: "3.9 million" },
{ name: "New York", population: "8,4 million" },
{ name: "Chicago", population: "2.7 million" },
]);
in component.html
<ul>
<li *ngFor="let city of myData$ | async">
{{city}}
</li>
</ul>
Error that I get:
ERROR Error: Cannot find a differ supporting object '[object Object]' of type 'Chicago'. NgFor only supports binding to Iterables such as Arrays.
of
operator instead offrom
operator in RxJs. – shiva krishna