成功插入数据库后,我试图打开角度材质对话框组件:
addHousehold(){
let last_name_ar = this.formGroup.controls['last_name_ar'].value;
let last_name_en = this.formGroup.controls['last_name_en'].value;
.......//Other data
let arrayOfLegalProtection = this.arrayOfLegalProtection;
this.showSpinner = true;
this.auth.addHousehold(this.unit_id,
...//Other data
this.user_id
).subscribe(
(data)=>{
console.log(data);
if(data=="enableAdd")
{
this.showSpinner = false;
this.enableDisableAdd = "enableAdd";
this.formGroup.reset();
this.arrayOfLegalProtection = [];
// this.openDialog(data);
this.openDialog();
}
else
{
this.showSpinner = true;
this.enableDisableAdd = "disableAdd";
this.formGroup.reset();
}
},
(error)=>{
console.log(error);
}
)
}
如您所见,我在方法(data)
部分添加了以下行subscribe()
:
this.openDialog();
具有openDialog()
以下代码:
openDialog(): void {
const dialogRef = this.dialog.open(AddIndividualComponent, {
width: '250px',
data: {unit_id: this.unit_id}
});
dialogRef.afterClosed().subscribe(result => {
console.log('The dialog was closed');
});
}
当插入数据库成功时,对话框不会打开,并且控制台上不会显示任何错误。
当我移动this.openDialog()
订阅方法的外部时,对话框正常打开。
我什至尝试在 subscribe() 中从头开始声明该函数,但我收到一条错误消息,提示找不到openDialog()
.
添加到数据库并收到成功响应后如何打开角度材料对话框?