我正在使用JQuery 1.3.8和ui.bootstrap版本:0.12.0。
当我在控制器中使用$modalInstance
时,我的页面无法加载,但如果我将其删除,页面工作正常,但模态命令不起作用。
我的代码:
angularFormsApp.controller('efController',
function efController($scope, $window, $routeParams, $modalInstance ,DataService) {
if ($routeParams.id)
$scope.employee = DataService.get_employee($routeParams.id);
else
$scope.employee = { id: 0 };
//$scope.employee = DataService.employee;
$scope.editableEmployee = $scope.employee;
$scope.departments = [
"Engineering",
"Management",
"Finance",
"IT"
];
$scope.submitForm = function () {
if ($scope.editableEmployee.id = 0) {
DataService.insertEmployee($scope.editableEmployee);
}
else {
DataService.updateEmployee($scope.editableEmployee);
}
$scope.employee = angular.copy($scope.editableEmployee);
//$window.history.back();
$modalInstance.close();
};
$scope.cancelForm = function () {
//$window.history.back();
alert($modalInstance);
$modalInstance.dismiss();
};
});
我使用open方法的代码: angularFormsApp.controller( “HomeController的”, 函数($ scope,$ location,$ modal,DataService){
$scope.showCreateEmployeeForm = function () {
//$location.path('/newEmployeeForm');
$modal.open({
templateUrl: "app/EmployeeForm/efTemplate.html",
controller: "efController"
});
};
$scope.showUpdateEmployeeForm = function (id) {
$location.path('/updateEmployeeForm/'+ id );
};
});
请帮我解释为什么页面无法加载。我正在使用.NET的MVC模板。
答案 0 :(得分:0)
angular.module('myModule', ['ui.bootstrap']);
您是否在模块配置中包含了 BootStrap依赖,就像上面的代码一样,这是必要的 我们使用Boot Strap时添加请检查