我无法将ngCookies角度模块注入我的项目中。你能告诉我为什么吗?我已完成了文档中的所有说明。如果可能的话,写真正的代码。
var mainApp = angular.module('mainApp',["ngCookies","ngRoute"]).config(appConfig);
appConfig.$inject=['$routeProvider','$cookieStore','$cookies'];
function appConfig ($routeProvider){
$routeProvider
.when(
'/add',
{
templateUrl:"view/add/index.html"
}
)
.when(
'/login',{
templateUrl:'view/login/index.html',
controller:'loginController'
}
)
.otherwise({
redirectTo:'/'
})
};
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<script src="assets/js/jquery/dist/jquery.js" charset="utf-8"></script>
<script src="assets/js/angular/angular.js" charset="utf-8"></script>
<script src="assets/js/angular-cookie/angular-cookie.js"></script>
<script src="assets/js/angular-route/angular-route.js" charset="utf-8"></script>
<script src="assets/js/angular-resource/angular-resource.js" charset="utf-8"></script>
<script src="assets/js/app/main.js" charset="utf-8"></script>
<script src="assets/js/app/controllers/loginController.js"></script>
<script src="assets/js/app/services/userLogin.js"></script>
</head>
<body>
<div ng-app = "mainApp" class="main">
<a id="add" href="#add">Дальше</a>
<a href="#">Назад</a>
<a href="#login">Логин</a>
<div ng-view>
</div>
</div>
</body>
</html>
错误如:
angular.js:68未捕获错误:[$ injector:modulerr]由于以下原因导致无法实例化模块mainApp: 错误:[$ injector:modulerr]由于以下原因导致无法实例化模块ngCookies: 错误:[$ injector:nomod]模块'ngCookies'不可用!您要么错误拼写了模块名称,要么忘记加载它。如果注册模块,请确保将依赖项指定为第二个参数。 http://errors.angularjs.org/1.4.4/ $注射器/ NOMOD?P0 = ngCookies