如何用删除可观察到的 - 角
我试图从可观察到的所有内容中删除所有内容,但它不起作用:
这是我到目前为止所做的:
deleteAllHistory(Histories$:Observable<History[]>){
Histories$.forEach((history)=>{this.deleteHistory(history.id)})
}
当我单击组件中的按钮时,我会触发此功能。这是处理我的组件.ts中删除的功能:
Histories$=this.facade.Histories$;
histo:History[];
this.Histories$.subscribe(history => {
this.histo = history as History[];
})
onDeleteAll(){
this.historyService.deleteAllHistory(this.histo);
}
但是它没有删除任何内容,我想是因为我必须从可观察的:历史记录$中删除。
谢谢您的宝贵时间!
根据要求,帖子呼叫:
addHistory(history:History){
return this.http.post(this.apiURL, history);
}
这是模板的标准:
<ng-container *ngIf="Histories$ | async">
<ng-container
*ngFor="let group of Histories$ | async | groupByDay"
>
<strong>{{ group[0] | date:'longDate'}}</strong>
<br />
<br />
<div *ngFor="let history of group[1]">
<mat-list-item class="historyClicking" (mouseover)="history.showTrash=true" (mouseout)="history.showTrash=false" (click)="onclick()">
<div class="block">
<div matList>{{history.SNS}}</div>
<div matList>{{history.title}}</div>
<div matList>{{history.DMC}}</div>
I am trying to delete everything from an observable but it doesn't work :
This is what I did so far in my service:
deleteAllHistory(Histories$:Observable<History[]>){
Histories$.forEach((history)=>{this.deleteHistory(history.id)})
}
I trigger this function when I click on a button in my component. This is the function that handles deletion in my component .ts :
Histories$=this.facade.Histories$;
histo:History[];
this.Histories$.subscribe(history => {
this.histo = history as History[];
})
onDeleteAll(){
this.historyService.deleteAllHistory(this.histo);
}
But it does not delete anything, I guess because I have to delete from the Observable : Histories$.
Thank you for your time !
As requested, the post call :
addHistory(history:History){
return this.http.post(this.apiURL, history);
}
This is par of the template :
<ng-container *ngIf="Histories$ | async">
<ng-container
*ngFor="let group of Histories$ | async | groupByDay"
>
<strong>{{ group[0] | date:'longDate'}}</strong>
<br />
<br />
<div *ngFor="let history of group[1]">
<mat-list-item class="historyClicking" (mouseover)="history.showTrash=true" (mouseout)="history.showTrash=false" (click)="onclick()">
<div class="block">
<div matList>{{history.SNS}}</div>
<div matList>{{history.title}}</div>
<div matList>{{history.DMC}}</div>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
对于HTTP请求,您需要订阅可观察的。
这是使用
forkjoin
forkjoinFor the http request to run you need to subscribe to the observable.
Here is how I would do it using
forkJoin