Skip to content Skip to sidebar Skip to footer

Typeerror: Cannot Read Property 'get' Of Undefined

$http.get('/contactList'). success(function(data){ console.log('got http get'); }). error(function(data) { $scope.error = true; $scope.data = data; return 'error na

Solution 1:

As other commenters said you should look at your controller declaration, you need to 'inject' the $http service:

angular.module('myApp')
.controller('messageController', ['$scope', '$http', function($scope, $http){
  $http.get()
  .success()
  .error();
}]);

Solution 2:

As I do not see any controller code, I would have to assume one out of the following could be causing this issue,

  1. You don't have all the dependencies injected in your controller as the commentators and @Plato has pointed out. Check this -> TypeError: Cannot call method 'get' of undefined

  2. You have injected all the dependencies but do not match the order, e.g., what should be ['$scope', '$http', function($scope, $http), you would have mentioned like this ['$scope', '$http', function($http, $scope). When using the array notation for injecting dependencies, the order of the arguments is important. Check this -> AngularJS $http.get returns undefined and $http() is not a function

Post a Comment for "Typeerror: Cannot Read Property 'get' Of Undefined"