'I don't know how to delete a list created from an observable
I was trying to delete something from a project I'm working on, and I don't know how to do a put server request. The put request works properly, but the view is not updated after receiving the response.
markNotificationsAsReaded(not): Promise<any> {
return new Promise((resolve, reject) => {
this.http.put(`${environment.url}/notifications/view`, { "notification_id": not.id }).pipe(map(res => { return res })).subscribe(
(res: any) => {
resolve(res);
console.log('marcando como leido esto 2', res)
},
error => {
reject();
});
})
}
and this is the HTML code
<app-notification
*ngFor="let n of notificationService.notificationsList$ | async; let idx=index"
[idx]="idx"
[notification]="n"[]
(removeNotification)="getNotification(idx)"
>
<h4 ></h4>
</app-notification>
I'm new in this, sorry if it is a basic error
Solution 1:[1]
you need to update the variable 'notificationService.notificationsList$. By default http request is made only once.
So even with the asynchronous pipe you will have to call the function that creates this list again.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Leo Chaves |
