$ mdDialog.show接受onComplete
函数,该函数在show动作完成后触发。请参阅https://material.angularjs.org/latest/api/service/ $ mdDialog#show。
如何从对话框控制器(而不是调用对话框的父控制器)中获取相同的onComplete功能?
答案 0 :(得分:0)
来自父控制器:
var onCompleteDeferred = $q.defer();
$mdDialog.show({
templateUrl: '/app/dialog.html',
controller: 'dialogController',
onComplete: onCompleteDeferred.resolve,
locals: {
loadingPromise: function () {
return onCompleteDeferred.promise;
},
success: function() {}
}
})
在对话框的控制器中:
myApp.controllers.controller("dialogController", [
"success",
"loadingPromise",
function (
success,
loadingPromise
){
loadingPromise().then(function() {
//everything in here is guaranteed to be ran AFTER the dialog has been opened
});
}
)