1 回答
TA贡献1886条经验 获得超2个赞
你可以这样做:
openModalConfirmationDialog(content1: TemplateRef<any>, row, content2:TemplateRef<any>, content3: TemplateRef<any>) {
// you can store row or data selected until page is active
this.contetntIWantToDelete = row;
// Make availale data in popup for confirmation
this.modalService.open(content1).then(result => {
if (result) {
// load the data (row) which is to be deleted
this.modalService.open(content2);
// update delete
this.yourDeleteinfoAPIcustomFunction('/name1/requestedWorkspaceDelete', row.id, content3);
}
});
}
yourDeleteinfoAPIcustomFunction(url, param, content1: TemplateRef<any>) {
// This function have success and error messages based on what is selected for deletion
this.http.get(baseUrl + url, options)
.subscribe(r => {
if (r != null) {
// success delete operation
} else {
// failed delete op.
}
}
}
在您的 html 删除按钮中:
(click)="openModalConfirmationDialog(modalConfirm, row, modalDeleteProgress, modalDeleteSuccess)"
在上面的函数中:我有一组在函数中传递的对话框,正如您提到的您想从对话框中获得确认:
<ng-template #modalConfirm>
<custom-directive>
<p>Confirm delete operation</p>
<p>Delete workspace Id: <B>{{workspace.id}}
<br></B><B>{{moreDetails}}</B>
</custom-directive>
</ng-template>
<ng-template #modalDeleteProgress>
<custom-directive type="warning" warningTitle="Delete in progress">
</custom-directive>
</ng-template>
<ng-template #modalDeleteSuccess>
<custom-directive type="success" successTitle="Success" btn="Close">
<div>workspace ID: {{workspace.id}} has been deleted</div>
</custom-directive>
</ng-template>
- 1 回答
- 0 关注
- 97 浏览
添加回答
举报