dialogRef.close()
Hi, How do i close my dialog from dialog calling compoent
(or)
I need to close my dialog while press the back button in my browser
You should import MdDialogRef in your child component and use it with your component.
import {MdDialogRef} from '@angular/material';
export class ModalComponent implements OnInit {
constructor(public dialogRef: MdDialogRef<ModalComponent>) {}
closeModal() {
this.dialogRef.close(); //call this code, when you want to close modal
}
}
The answer from @Golosay is correct. Closing as a non-issue.
I tried using this.dialogRef.close(). still not able to close popup. I am opening AdminComponent as a Popup.
Admin.component.ts-
export class AdminComponent implements OnInit {
constructor( public dialogRef: MdDialogRef
Thank you for your help
I have the same problem, dialogRef.close() does nothing. I tested with dialogRef.updateSize to be sure my import and initialization where correct. updateSize on the same modal works. The problem is with 0ne modal only, this modal is opened om top of a other modal.
onCancelClicked() {
console.log("onCancelClicked"); //works
this.dialogRef.close(); //does nothing
this.dialogRef.updateSize("150px","20px"); //works
}
I solved my problem, it was a @input statement that was badly configured in the parent view. error had nothing to do with material.
@switch87 - Can you please describe the input issue. I am facing a similar issue, it'd be really helpful.
@aykutyararbas I don't know what it was anymore. But it didn't have anything to do with the dialog at all.
@switch87 No worries, thanks.
This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem.
Read more about our automatic conversation locking policy.
This action has been performed automatically by a bot.