user1245524 user1245524 - 1 year ago 83
AngularJS Question

TypeError: AuthenticateService.checkUser is not a function

TypeError: AuthenticateService.checkUser is not a function

I am submitting a login page with credentials, for sending the credentials to the server I have service **AuthenticateService** with $, calling the method in the above mentioned service from the contactLoginCtrl.js (controller),
during that I am encountering this error

below is the code for AuthenticateService



checkUser : function(uname, pword){

var indata = { "password": pword, "username":uname };
var req ={
method: 'POST',
url: 'http://localhost:8083/spring2/login',
data: indata

$http(req).then(function (response) {
return response;
}, function (error) {
return error;




below is the controller code contactLoginCtlrls.js


$scope.authenticate = function(userModel){
var userName = userModel.username;
var password = userModel.password;


The above highlighted line is causing the error could some one please check this?

----------------------ignore the below section------------------------

content added only for skipping the error from stackoverflow to add some more detail

Answer Source

You controller does not have $rootScope injected as a parameter. Change it like this,

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download