Hey, I am using an observable to get 6 items from an API, and the observable is getting all the objects correctly, however when displaying them it seems to just repeat the last added object for the amount of objects there is.
html code
<div>
<table class="table table-light">
<thead>
<tr>
<th scope="col">Title</th>
<th scope="col">Price</th>
<th scope="col">Description</th>
</tr>
</thead>
<tbody>
<tr *ngFor="let list of listing$ | async">
<td>{{list.title}}</td>
<td>{{list.price}}</td>
<td>{{list.description}}</td>
</tr>
</tbody>
</table>
</div>
observable/ngOnInit code
listings: Listing[] = [];
listing$: Observable<Listing[]> = this.listingQuery.selectAll();
constructor(private listingService: ListingService, private listingQuery: ListingQuery) {}
ngOnInit() {
this.listListingsSub = this.listingQuery.selectAreListingLoaded$.pipe(
filter(areListingLoaded => !areListingLoaded),
switchMap(areListingLoaded => {
if (!areListingLoaded) {
return this.listingService.getAllListings().pipe(
map(result => {
console.log(result);
this.listings = result;
return result;
})
);
} else return '';
})
).subscribe(result => {console.log(this.listings)});
}