Reputation: 9222
I am getting the followin error
Error: [$injector:unpr] Unknown provider: AuthProvider <- Auth <- LoginCtrl
and my code looks like the following...
'use strict';
angular.module('yapp')
.controller('LoginCtrl', function($scope, $location,Auth,$log) {
$scope.submit = function(email,password) {
var model = {
email:'',
password:''
};
$scope.model = model;
Auth.login(email,password)
.then(function(token){
$log.info(token);
},function (error){
$log.info(error);
});
}
});
'use strict';
angular.module('yapp') .factory('Auth', function($http,$q,$log,APIHelper) {
var self = this;
this.login = function(email,password){
var d = $q.defer();
var requestUrl = APIHelper.endpoints.login;
var data = {
email:email,
password:password
};
$http({
url:requestUrl,
dataType: 'json',
method: 'POST',
data:data,
headers: {
"Content-Type": "application/json"
}
})
.success(function(data,status,headers,config){
d.resolve(data);
})
.error(function(data,status,headers,config){
d.reject(data);
});
return d.promise;
}
return self;
});
Upvotes: 1
Views: 1505
Reputation: 485
This usually happens when you haven't included the file in which you have defined the service. Are you sure you did a script import or a module.export for that?
Upvotes: 1