无法在AngularJS中注册模块
问题描述:
我有一个简单的前端应用程序,可以找到here。在我的索引文件我加载app.js先authentication.js服务:无法在AngularJS中注册模块
<script src="scripts/app.js"></script>
<script src="scripts/services/authentication.js"></script>
认证模块可以在scripts/services/authentication.js
文件中找到,看起来像这样:
'use strict';
angular.module('Authentication')
.factory('AuthenticationService',
['$http', '$rootScope',
function ($http, $rootScope) {
var service = {};
service.Login = function (username, password) {
$http.post('/users/authenticate', { username: username, password: password })
.success(function (response) {
console.log(response);
});
};
service.SetCredentials = function (token) {
$rootScope.localStorage.setItem('token', token);
$http.defaults.headers.common['Authorization'] = 'Bearer ' + token; // jshint ignore:line
};
service.ClearCredentials = function() {
$rootScope.removeItem('toke');
$http.defaults.headers.common.Authorization = 'Bearer ';
};
return service;
}]);
我非常新AngularJS和我只是遵循这个tutorial。我运行我的应用程序时遇到的问题是:
模块“身份验证”不可用。你要么拼写错误的模块名称或忘了装载它...
我试图在index.html文件中交换app.js和authentication.js,但得到了'Module frontendApp is not available'。我真的很想知道,为什么这样一个基于教程的简单代码不起作用。 – Jacobian