I have an observable that simply gives the double of values from 1 to 5:
obs = new Observable(observer => {
console.log('Observable starts')
observer.next(1);
observer.next(2);
observer.next(3);
observer.next(4);
observer.next(5);
observer.complete();
}).pipe(
tap(data => console.log('tap ' + data)),
map((val) => { return val as number * 2 }),
tap(data => console.log('final ' + data)),
)
To get the values in UI, I wrote the following line of code:
this.obs.subscribe({ next: val => { this.var1 = val } })
Now, when I am trying to retrieve these values in UI using NgFor, *ngFor="let v1 of var1"
UI code
I am getting the error as: Type 'number' is not assignable to type 'NgIterable | null | undefined'.
How can I get the values to show up in UI? Where am I going wrong with my above code?