我按照文档制作了有效的 md-dialog,但我一直停留在功能失调的按钮上,该按钮会触发对话框。一旦对话框打开和关闭,触发按钮(在该控制器中使用脚本的所有内容)似乎都无法正常工作。
这是CodePen和代码。
var app = angular.module('app', ['ngMaterial', 'ngAnimate']);
// Dialog controller
app.controller('showDialogCtrl',
function ($scope, $mdDialog) {
// Showing order form dialog
$scope.showDialog= function($event){
$mdDialog.show({
targetEvent: $event,
clickOutsideToClose: true,
scope: $scope,
template:
'<md-dialog>' +
' <md-dialog-content>Hello!</md-dialog-content>' +
' <md-dialog-actions>' +
' <md-button ng-click="closeDialog()" class="md-primary">' +
' Close' +
' </md-button>' +
' </md-dialog-actions>' +
'</md-dialog>',
parent: angular.element(document.body),
controller: DialogController,
});
function DialogController($scope, $mdDialog) {
$scope.closeDialog = function() {
$mdDialog.hide();
};
};
}
});
<md-button ng-controller="showDialogCtrl" ng-click="showDialog($event)">
Click
</md-button>