I have a simple frontend application, which can be found here. In my index file I load app.js first and then authentication.js service:
<script src="scripts/app.js"></script>
<script src="scripts/services/authentication.js"></script>
Authentication module can be found in scripts/services/authentication.js file and looks like so:
'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;
}]);
I'm extremely new to AngularJS and I'm just following this tutorial. The problem I get, when I run my application is:
Module 'Authentication' is not available. You either misspelled the module name or forgot to load it...
Module frontendApp is not available. I really wonder, why such a simple code, based on tutorials does not work.