I am just starting to learn about angular js. In the project I am currently working on, I have created a code snippet for authorization in a directive. However, when I try to call the validateUser function, the $http post call does not seem to be executing as expected.
authorizationModule.factory('authorizationFactory',['$http','$q',function(http,q) {
return {
validateUser : function(input){
var deferred = q.defer();
http({
url: '/OutageRequest/AuthenticationServlet',
method: 'post',
data: {'authCode': input }
}).
success(function(data, status, headers, config) {
console.log(data);
deferred.resolve(data);
}).
error(function(data, status, headers, config) {
console.log(status);
deferred.reject();
});
return deferred.promise;
}
}
Can anyone help me figure out what might be going wrong in my code?