angular.module('site.controllers', ['ngCookies'])
.controller("LoginController", ["$scope", "$http", "$cookies", function($scope, $http, $cookies){
debugger; // can access $cookies here
$scope.login = function(){
debugger; // ReferenceError: $cookies is not defined
var credentials = {
'username': $scope.username,
'password': $scope.password
};
$http.post('/login', credentials)
.success( function(data, status, headers, config){
$scope.template = $scope.templates[2];
})
.error( function(data, status, headers, config){
debugger;
$scope.template = $scope.templates[2];
//TODO: info for user that login failed
});
};
}])
;
I have no idea why $cookies service is available in LoginController direct body, but it is not available in LoginController's login function.
$scope and $http are available in both places, however the $cookies service is problematic.
These files are included in HTML head:
<script type="text/javascript" src="static/lib/angular/angular.js"></script>
<script type="text/javascript" src="static/lib/angular/angular-cookies.js"></script>