简体   繁体   中英

Documentation on Angular Material $mdDialog.finally?

From the documentation , dialog boxes in Angular Material have a signature like so:

function showAlert() {
  alert = $mdDialog.alert()
    .title('Attention, ' + $scope.userName)
    .content('This is an example of how easy dialogs can be!')
    .ok('Close');
  $mdDialog
      .show( alert )
      .finally(function() {
        alert = undefined;
      });
}

I can't seem to find any documentation on .finally . It appears to be a callback function from what I can gather, though the documentation is oddly lacking any info.

Should I assume it is a normal callback function—and why is the documentation on it lacking—is this simply such standard directive syntax that this is assumed to be the way to deal with callbacks, like .then ?

Thanks for any information.

$mdDialog.show() returns a promise. finally is an action that you take on completion of a promise, regardless of if it was resolved or rejected. Typically, finally is used to handle whatever cleanup should be done once the promise has completed (just like it does here by clearing the alert variable).

Angular uses the q library to handle promises, so you can find information on the finally() method at the Q API Reference

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM