components icon indicating copy to clipboard operation
components copied to clipboard

dialogRef.close()

Open dharveshmydeen opened this issue 9 years ago • 9 comments

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

dharveshmydeen avatar Apr 17 '17 07:04 dharveshmydeen

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
   }
}

Golosay avatar Apr 17 '17 08:04 Golosay

The answer from @Golosay is correct. Closing as a non-issue.

crisbeto avatar Apr 17 '17 19:04 crisbeto

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) {} closeModal() { console.log('closing'); this.dialogRef.close(); } }

Thank you for your help

VishalChorghe avatar Oct 05 '17 08:10 VishalChorghe

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 }

switch87 avatar Nov 02 '17 07:11 switch87

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 avatar Nov 02 '17 08:11 switch87

@switch87 - Can you please describe the input issue. I am facing a similar issue, it'd be really helpful.

aykutyararbas avatar Jan 22 '18 05:01 aykutyararbas

@aykutyararbas I don't know what it was anymore. But it didn't have anything to do with the dialog at all.

switch87 avatar Jan 22 '18 12:01 switch87

@switch87 No worries, thanks.

aykutyararbas avatar Jan 23 '18 03:01 aykutyararbas

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.