question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

close dialog from it's own controller

See original GitHub issue

Bug, feature request, or proposal:

Feature request or proposal

What is the expected behavior?

How can I close md-dialog from it’s own controller and send data without clicking a buttons in md-dialog-actions container?

What is the current behavior?

It is not possible to close dialog and share data from the dialog controller.

What are the steps to reproduce?

Create md-dialog component and try to close it with sending a data by click on the element in md-dialog-content.

What is the use-case or motivation for changing an existing behavior?

I have an items list in the md-dialog. Every item have a checkbox and title. I wont to add checked items to data and send them by click on the md-dialog-actions button. And I want to add one item to the data, send it to parent controller and close dialog by click on the item title. How can I do it without crutches?

Which versions of Angular, Material, OS, TypeScript, browsers are affected?

Angular 4+, Material beta.7

Is there anything else we should know?

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

6reactions
willshowellcommented, Jun 22, 2017
// FermentablesAddDialogComponent

constructor(
  private dialogRef: MdDialogRef<FermentablesAddDialogComponent>,
  @Inject(MD_DIALOG_DATA) public data: any
) { }

closeMyself() {
  this.dialogRef.close(123);
}

It’s in the dialog overview page of the docs, but it’s a little hidden

Components created via MdDialog can inject MdDialogRef and use it to close the dialog in which they are contained. When closing, an optional result value can be provided. This result value is forwarded as the result of the afterClosed promise.

3reactions
twoheadedcommented, Jun 22, 2017

It works great! I think that this small example should be added to the documentation. Thank you

Read more comments on GitHub >

github_iconTop Results From Across the Web

Need to close Jquery UI dialog from controller action in ...
An alternative would be to handle the save click in jquery, use .serialize to send the form collection to your controller, then close...
Read more >
Dialog (JavaFX 8)
A Dialog in JavaFX wraps a DialogPane and provides the necessary API to present it to end users. In JavaFX 8u40, this essentially...
Read more >
Close Dialog when click outside of its region
Close Dialog when click outside of its region ... By default, dialog can be closed by pressing Esc key and clicking the close...
Read more >
How to close lightning quick action modal dialog
I created a lightning component as a quick action button. In the component, I have a cancel button that I want it closed...
Read more >
Services > $mdDialog
ok: 'Close' }); $mdDialog .show( alert ) .finally(function() { alert = undefined; }); ... Greeting controller used with the 'showCustomGreeting()' custom dialog ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found