I am calling modal popup from my controller. It works fine for the first time but doesn't show the second time. Here is the code for the show
$scope.showAdvanced = function (ev) {
var scopeVar = $scope;
console.log('$mdDialog');
console.log($mdDialog);
$mdDialog.show({
controller: DialogController,
templateUrl: 'dialog1.tmpl.html',
parent: angular.element(document.body),
scope: $scope,
targetEvent: ev,
clickOutsideToClose: true
}).then(function (result) {
//$scope = $scope.$parent;
console.log($scope);
});
};
Here is my hide function inside DialogController.
$scope.hide = function () {
console.log('hide called');
$mdDialog.hide();
console.log('hide completed');
};
Hide is executing successfully and followed by callback defined in show which prints the current scope. If I remove scope : $scope and put transclude : true then it is not showing the data in dialog controller though you can show and hide it more than once.
Add preserveScope: true
to your modal options. A dialogue removes its scope on closing by default.