md-dialog Before close functionality?
See original GitHub issueBug, feature request, or proposal:
Feature?
What is the expected behavior?
When user clicks on backdrop
or esc
the dialog closes. It would be nice to give the user the option to intercept this close method and prevent default behavior based on some condition.
What is the use-case or motivation for changing an existing behavior?
For example if Dialog contains a form, to be able to disable close or display a message (or whatever function he/she wants to run) and prevent the modal from closing.
Issue Analytics
- State:
- Created 6 years ago
- Comments:7 (4 by maintainers)
Top Results From Across the Web
mdDialog: catch the onClose event - angularjs - Stack Overflow
So I'm looking for way to call a function BEFORE the pop-up actually closes. Something like scope.$on("$mdDialogBeforeClose", function () { ...
Read more >Services > $mdDialog - AngularJS Material
.md-dialog-content - class that sets the padding on the content as the spec file ... ok: 'Close' }); $mdDialog .show( alert ) .finally(function()...
Read more >Closing MdDialog with md-dialog-close on button refreshes ...
I have the exact same functionality on two other dialogs except that those two are not prepopulated with forms.
Read more >Services > $mdDialog - AngularJS Material - Introduction
.md-dialog-content - class that sets the padding on the content as the spec file ... ok: 'Close' }); $mdDialog .show( alert ) .finally(function()...
Read more >Angular Material - Dialogs - Tutorialspoint
Angular Material - Dialogs, The md-dialog, an Angular Directive, is a container element ... dialogController); function dialogController ($scope, $mdDialog) ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@dfmmalaw this won’t be available until https://github.com/angular/material2/pull/6682 lands. It could look like this:
beforeClose
(#4647) will eventually be implemented to give users the ability to respond immediately instead of waiting for the animation to complete. However, it won’t allow cancelling the close.So in order to cancel the close (e.g. to show a message when the form needs to be saved or whatever), you would have to pass
disableClose
to the dialog. Then you would be able to subscribe tobackdropClick
andescapeKeyEvent
streams to show the message or close the dialog on your own.Those two streams are not yet available and that’s what #3460 is all about (particularly the last ~5-6 comments). However, once https://github.com/angular/material2/issues/6330 is completed, that will be easy work to make them part of the dialog’s public api.
In summary, I doubt they’ll be in the next release, but probably in the following 1-2.