我已經建立了簡單的角度頁,但除ui.bootstrap到依賴後,我得到了一個錯誤:
Error: [$injector:unpr] http://errors.angularjs.org/1.4.8/$injector/unpr?p0=%24modalProvider%20%3C-%20%24modal%20%3C-%20HomeController
下面是引用部分
<link href="Content/bootstrap.min.css" rel="stylesheet" />
<script src="Scripts/angular.min.js"></script>
<script src="Scripts/angular-route.min.js"></script>
<script src="Scripts/angular-ui/ui-bootstrap-tpls.min.js"></script>
<script src="app/AngularFormsApp.js"></script>
<script src="app/EmployeeForm/efController.js"></script>
<script src="app/EmployeeForm/efDirective.js"></script>
<script src="app/DataService.js"></script>
,這是我的應用程序的js:
var angularFormsApp = angular.module('angularFormsApp',['ngRoute','ui.bootstrap']);
angularFormsApp.config(function($routeProvider) {
$routeProvider
.when("/home", {
templateUrl: "app/Home.html",
controller: "HomeController"
}).when("/newEmployeeForm", {
templateUrl: "app/EmployeeForm/efTemplate.html",
controller: "efController"
}).when("/updateEmployeeForm/:id", {
templateUrl: "app/EmployeeForm/efTemplate.html",
controller: "efController"
}).otherwise({
redirectTo:"/home"
});
});
angularFormsApp.controller("HomeController",
function ($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);
};
});
任何想法,我才錯index.html文件嗎? Whitout ui.bootstrap引用該頁面運行良好。
您是否包含'$ modal'的源代碼? – tymeJV
是的。這裏:函數($ scope,$ location,$ modal,DataService){ – arth81
您是否需要包含'ui-bootstrap.js'和'ui-bootstrap-tpls.js'文件或做了更改? – jcc