My application has an Observable that contains an array of places:
places: Observable<Array<any>>;
In the template, I am using the async pipe to iterate over the array:
<tr *ngFor="let place of places | async">
...
</tr>
After certain user actions, I need to remove a place with a specific id from this array. However, the code snippet I have tried does not work as expected:
deletePlace(placeId: number): void {
this.apiService.deletePlace(placeId)
.subscribe(
(res: any) => {
this.places
.flatMap((places) => places)
.filter((place) => place.id != placeId);
},
(err: any) => console.log(err)
);
}
Can anyone provide guidance on how to achieve this functionality?