我不知道如何删除从可观察对象创建的列表
I don't know how to delete a list created from an observable
我试图从我正在处理的项目中删除某些内容,但我不知道如何执行放置服务器请求。
put请求正常,但是收到response后view没有更新
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();
});
})
}
这是 HTML 代码
<app-notification
*ngFor="let n of notificationService.notificationsList$ | async; let idx=index"
[idx]="idx"
[notification]="n"[]
(removeNotification)="getNotification(idx)"
>
<h4 ></h4>
</app-notification>
我是新手,如果是基本错误请见谅
您需要更新变量“notificationService.notificationsList$。默认情况下,只发出一次 http 请求。
因此,即使使用异步管道,您也必须再次调用创建此列表的函数。
我试图从我正在处理的项目中删除某些内容,但我不知道如何执行放置服务器请求。 put请求正常,但是收到response后view没有更新
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();
});
})
}
这是 HTML 代码
<app-notification
*ngFor="let n of notificationService.notificationsList$ | async; let idx=index"
[idx]="idx"
[notification]="n"[]
(removeNotification)="getNotification(idx)"
>
<h4 ></h4>
</app-notification>
我是新手,如果是基本错误请见谅
您需要更新变量“notificationService.notificationsList$。默认情况下,只发出一次 http 请求。
因此,即使使用异步管道,您也必须再次调用创建此列表的函数。