我是Angular的新手,并且对AngularUI模式对话框的文档感到困惑。我看不出那里提供的代码如何适合主页的控制器,或者主页上的按钮在点击时如何打开模态对话框。
http://angular-ui.github.io/bootstrap/
ModalDemoCtrl
是否应该追加到主页应用的控制器?
var myApp = angular.module('myApp', ['ui.bootstrap']);
var ModalDemoCtrl = function($scope, $modal, $log) {
<snip>
}
myApp.controller("ModalDemoCtrl");
或ModalDemoCtrl
函数对象是否只是嵌套在主页面的控制器中?
var myApp = angular.module('myApp', ['ui.bootstrap']);
myApp.controller("MainPageCtrl", function($scope, $modal, $log) {
var ModalDemoCtrl = function($scope, $modal, $log) {
<snip>
}
});
答案 0 :(得分:1)
基本上它是一个常规控制器:
var modal = $modal.open({
templateUrl: 'deleteDialog.html',
controller: 'deleteDialogController'
});
modal.result.then(function () {
});
deleteDialogController.js文件:
appModule.controller("deleteDialogController", [ "$scope", "$modalInstance",
function ($scope, $modalInstance)
{
$scope.ok = function () {
$modalInstance.close();
};
$scope.cancel = function () {
$modalInstance.dismiss('cancel');
};
}
]);