I was reading up on details of mdDialog in Material Design, and couldn't understand why an alert popup would return a promise. Can someone explain how a promise is returned by a mdDialog through an example?
The documentation for Material Design mdDialog said the following:
$mdDialog opens a dialog over the app to inform users about critical information or require them to make decisions. There are two approaches for setup: a simple promise API and regular object syntax.
It returns a promise
because you probably want to react to future events in different way, like close
(resolve the promise) and cancel
(reject it).
mdDialod.show()
returns a promise, as written in documentation, so you can just resolve or reject it (as mentioned above, with close
and cancel
methods on $mdDialog
service).
Here is a simple example as you requested (open the console to see how it logs the appropriate text for each event).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With