私は簡単なフロントエンドアプリケーションを持っています。これはhereです。認証モジュールは、scripts/services/authentication.js
ファイルで見つかったので、のように見えることができモジュールをAngularJSに登録できません
<script src="scripts/app.js"></script>
<script src="scripts/services/authentication.js"></script>
:
'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;
}]);
私はに非常に新しいです、私のインデックスファイルでは、私はapp.js最初にしてauthentication.jsサービスを読み込みますAngularJSと私はちょうどこれに従っていますtutorial。私のアプリケーションを実行すると、私が得る問題は:
モジュール '認証'は利用できません。あなたは、どちらかのモジュール名をスペルミスか、それをロードするために忘れてしまった...あなたが同じファイルに2つのモジュールをロードしようとしているので
app.jsとauthentication.jsをindex.htmlファイルに入れ替えようとしましたが、「Module frontendApp is not available」を取得しました。私は本当に、なぜチュートリアルに基づいて、そのような単純なコードが動作しないのだろうかと思います。 – Jacobian