Goal : Open dialog on page load. Check to make sure its not already open so it only opens once. The dialog is a separate component.
Problem : Its opening twice.
I tried checking, but the condition never becomes true. I was using information from SO articles like Angular Material | Check if dialog is open but they mention MatDialogRef?
TS :
ngOnInit()
{
// Set InActiveV back to false incase p refreshes page so that chat will call StartPVQueue
sessionStorage.setItem('InActiveV', "false");
// Start visit in API and get medical info
const staring = timer(500, 10000);
this.startVSubscription = staring.subscribe(val =>{
if (!this.isLoad) {
this.PStartV();
//this.cmdOpenDialog_OnInit();
}
else {
this.startVSubscription.unsubscribe();
}
});
this.cmdOpenDialog_OnInit();
}
cmdOpenDialog_OnInit() {
if (!this.dialog) {
return;
}
this.dialog.open(DialogInternalNotesThreeComponent, {
data: {
data: this.internalNotes
}
});
}
You can store a reference to the dialog on your component:
cmdOpenDialog_OnInit() {
if(this.dialogRef) {
return;
}
this.dialogRef = this.dialog.open(DialogInternalNotesThreeComponent, {...});
this.dialogRef.afterClosed().subscribe(() => {
this.dialogRef = null;
})
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.