I'm tring to close dialog by this manner :
showAlert(ev) {
this.mdDialog.show({
restrict: 'E',
template:'<loader></loader>' +
' <md-button ng-click="this.mdDialog.hide()" class="md-primary">' +
' Close Dialog' +
' </md-button>' ,
parent: angular.element(document.body.childNodes[5]),
clickOutsideToClose:true
});
};
closeDialog() {
this.mdDialog.hide();
};
but the button appears and do nothing. Any idea ?
I found the answer there http://webiks.com/mddialog-with-a-confirmation-dialog/ ,
in the last plunker in page https://embed.plnkr.co/HiLJlsp0yfcukxi2McNZ/ .
the scope property was not needed.
P.S
Now I see @camden_kid answer after edition was, correct for me as well, thanks.
Here you go - CodePen
Markup
<div ng-controller="MyController as vm" class="md-padding" ng-cloak="" ng-app="app">
<md-button class="md-primary md-raised" ng-click="vm.show($event)">Open</md-button>
</script>
</div>
JS
angular.module('app',['ngMaterial'])
.controller('MyController', function($scope, $mdDialog) {
this.show = function(ev) {
$mdDialog.show({
restrict: 'E',
template:'<loader></loader>' +
' <md-button ng-click="vm.hide()" class="md-primary">' +
' Close Dialog' +
' </md-button>' ,
parent: angular.element(document.body),
clickOutsideToClose:true,
targetEvent: ev,
controller: DialogController,
controllerAs: "vm"
});
};
});
function DialogController($scope, $mdDialog) {
this.hide = function() {
$mdDialog.hide();
};
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With