我打开Dialog Window
(有own controller
)。
我想更改属于differentController
的{{1}}中的数据,Dialog Window
将数据发送回onRemoving
并应用数据。有可能吗?
parent controller
答案 0 :(得分:1)
当您在对话框的控制器上调用$mdDialog.hide([response]);
函数时,此[response]
将作为参数传递给$mdDialog.show()
函数返回的承诺。
如果您致电$mdDialog.hide([response]);
承诺将得到解决,如果您致电$mdDialog.cancel([response]);
承诺将被拒绝。
function openTaskDialog(ev, test)
{
$mdDialog.show({
controller : 'differentController',
controllerAs : 'vm',
templateUrl : 'dialog.html',
parent : angular.element($document.body),
targetEvent : ev,
clickOutsideToClose: true,
onComplete: onComplete,
onRemoving: function (event, promise) {
console.log('onRemoving',event, promise, $mdDialog)
},
locals : {
Test : test,
event: ev
}
}).then(function(response){
})
.catch(function(responseIfRejected){
})
.finally(function(){
})
}
function onComplete (scope, el, options) {
console.log('scope, el, options', scope, el, options)
}
function differentController($mdDialog){
this.save = function(){
$mdDialog.hide({ message: 'success' });
};
this.cancel = function(){
$mdDialog.cancel({ message: 'fail' });
};
}