有关Angular Material $ mdDialog.finally的文档? [英] Documentation on Angular Material $mdDialog.finally?

查看:89
本文介绍了有关Angular Material $ mdDialog.finally的文档?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

通过文档中的对话框Angular Material的签名如下:

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

我似乎找不到.finally上的任何文档.尽管文档奇怪地缺少任何信息,但据我看来,它似乎是一个回调函数.

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.

我应该假定它是一个普通的回调函数,为什么缺少有关它的文档,这仅仅是这样的标准指令语法吗?它被假定为处理回调的方式,例如.then?

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()返回承诺. finally是您在完成诺言时采取的行动,无论它是已解决还是被拒绝.通常,finally用于处理诺言完成后应该执行的任何清理操作(就像在这里通过清除alert变量一样).

$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使用q库处理承诺,因此您可以在

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

这篇关于有关Angular Material $ mdDialog.finally的文档?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆