Angularjs ui.bootstrap 0.12中的$modalInstance不工作
我正在使用jQuery1.3.8和ui.bootstrap版本:0.12.0 当我在控制器中使用$modalInstancein时,我的页面不会加载,但如果我删除它,页面可以正常工作,但模态命令不起作用 我的代码:Angularjs ui.bootstrap 0.12中的$modalInstance不工作,angularjs,twitter-bootstrap,asp.net-mvc-4,angular-ui,Angularjs,Twitter Bootstrap,Asp.net Mvc 4,Angular Ui,我正在使用jQuery1.3.8和ui.bootstrap版本:0.12.0 当我在控制器中使用$modalInstancein时,我的页面不会加载,但如果我删除它,页面可以正常工作,但模态命令不起作用 我的代码: angularFormsApp.controller('efController', function efController($scope, $window, $routeParams, $modalInstance ,DataService) { if ($route
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();
};
});
我使用开放式方法的代码:
angularFormsApp.controllerHomeController,
函数$scope、$location、$modal、数据服务{
$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模板
angular.module('myModule', ['ui.bootstrap']);
您是否像上面的代码一样在模块配置中包含引导依赖项,这是必要的
要在使用引导时添加,请选中它请在解析方法中调用$modal.open来显示创建thr$modalInstance的代码。如果您没有这样的方法,只是尝试注入$modalInstance,那么这就是您的问题。感谢您的回复。是的,我包括在内。var angularFormsApp=angular.module'angularFormsApp',['ngRoute','ui.bootstrap']