将数据从模态传递到组件



我有一个带有分页的用户列表。我用ngbModal来做弹出窗口。在关闭模态上,我如何将页面数据从编辑用户模态发送到用户组件?

<对话服务/strong>

openDialog(props: any, component:any): Promise<any> {
debugger
console.log(props)
var modelRef = this.ngbModel.open(component, { size: 'md  ', backdrop: 'static' });
modelRef.componentInstance.props = props;
return modelRef.result;
}

用户component.ts

opendialog(data: any) {
this.dialogService
.openDialog(
{
title: 'Edit User',
page:`page=${this.page}&size=${this.pageSize}`
type: 'edit',
},
EditComponent
)
.then((res: any) => {
console.log(res);
});
}

编辑modal.ts

setDialogProps(dialogdata: any) {
this.pages= dialogdata.page; 
}
editUser(){
this.userService.edit(this.form.value,id).subscribe((res:any)=>{
this.ngbActivemodal.close(this.pages)
})
}

matdialgref有afterClosed可观察对象,你可以用它来获取数据。

https://material.angular.io/components/dialog/api

以下是官方材料文档中的示例。

最新更新