var login_app = angular.module('login_app',[]);
login_app.factory('login_service', function($http) {
return {
loginUser: function() {
//return the promise directly.
return $http.get('/service/login')
.then(function(result) {
//resolve the promise as the data
return result.data;
});
}
}
});
login_app.controller('login_controller',
['$scope','login_service'
function($scope, login_service){
$scope.login_username = "";
$scope.login_password = "";
$scope.remember_login = false;
$scope.login_button_action = function(){
login_service.loginUser();
}
}]);
I have a login form integrated with this controller and everything seems to be functioning properly. Whenever I click on the login button, it triggers the login_button_action through ng-click directive.
I'm encountering an issue where my JavaScript console keeps showing this error message.
ReferenceError: login_service is not defined
Do you see any issues with how my controller is utilizing the service?