There is an Observable of the array of places:
places: Observable<Array<any>>;
In template it used with the async pipe:
<tr *ngFor="let place of places | async">
...
</tr>
After some user actions I need to remove the place with specific id from this array. I have something like this in my code, but it doesn't work:
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 you help me with this?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…