Reputation: 402
I want to close $mdDialog after a successful promise return.
I can close $mdDialog like my following code but it doesn't fill my necessity on this purpose
vm.$mdDialog.show({
controller: 'myController',
templateUrl: 'myfile.html',
clickOutsideToClose: true,
controllerAs: "vm",
locals: {
}
});
Can anyone help me providing any code snippet of a function with which i can close the Dialog after a promise return or anywhere i want to close that
Upvotes: 1
Views: 73
Reputation: 48968
it didn't return to the mother controller, from where the
$mdDialog
is called
The $mdDialog.show()
method returns a promise that resolves with data or promise provided to the $mdDialog.hide()
method:
var promise = vm.$mdDialog.show({
controller: 'myController',
templateUrl: 'myfile.html',
clickOutsideToClose: true,
controllerAs: "vm",
locals: {
}
});
promise.then(function(data) {
console.log(data);
}).catch(function(reason) {
console.log("Cancelled", reason);
});
$http.get(url).then(function(response) {
$mdDialog.hide(response.data);
});
Upvotes: 2