Hello, I do not undestand why this simple ngfor give me a error on html, I used async pipe. https://github.com/JasminDeVisbe/angular-ivy-ts-strict-enabled-itj126/blob/main/src/app/app.component.html
#NgFor on Observable failed
3 messages · Page 1 of 1 (latest)
myObservableArray$: Observable<MyDataType[]> = of();
of() does not emit an iterable value
@Component({
template: `
<div *ngFor="let item of myObservableArray$ | async">
{{ item.value }}
</div>
`,
})
export class AppComponent {
public readonly myObservableArray$: Observable<MyDataType[]>;
constructor(private myService: MyService) {
this.myObservableArray$ = this.myService.getData();
}
}
But IMPO, .getData() should be .data$ because a method would create new Observables every time invoked which would be poor design.