我正在尝试将前端(Angular)添加到后端应用程序,而我在这方面的经验很少,所以我陷入了困境。
以下代码显示错误。
该代码与弹出窗口相关,具有两个选项:“确定”和“退出”。
选择“确定”时会发生这种情况。
该代码应该从数据库中删除数据(会发生)并隐藏弹出窗口(不会发生)。
private deleteNeed: EmitType<object> = () => {
console.log(this.needToDelete);
this.needService.delete(this.needToDelete).subscribe( r => {
this.toastService.success('Need deleted!');
this.ejDialog.hide();
this.loadNeeds();
},e => {
this.toastService.error('Error');
console.log(e);
}
);
}
出于某些原因,这些行:
this.toastService.success('Need deleted!');
this.ejDialog.hide();
this.loadNeeds();
似乎被忽略了,执行转到错误部分。
方法“隐藏”工作正常,我知道这是因为,如果在上述弹出窗口中选择“退出”按钮,则所有按钮都可以正常工作,并且该窗口被隐藏。
单击“确定”按钮后,将从数据库中删除了数据(需要),但是弹出窗口仍然存在,必须单击“删除”按钮才能删除该数据。
我不知道为什么。
有没有类似的经历?
this.needService.delete的详细信息:
constructor(private needService : NeedService,
private toastService: ToastService) {
this.dataManager = new DataManager({
json: this.needsList, adaptor: new
NeedsDataAdaptor(this.needService)
});
}
delete(need: Need) : Observable<Need> {
console.log('Need deleted!');
console.log(need);
return this.http.patch(urlDel, need).pipe(
map(res => res.json())
);
}