6

I have read through all the posts where people get this issue where $http is not a function, and it looks like for the most part it is due to injections being done in the wrong order.

My module definition looks like this:

angular.module("app", []).controller("appCtrl", ['$scope','$http',
    function ($scope, $http) {

...

    $scope.makeCall= function ($http) {
         console.log("HERE");
         $http({ method: 'GET', url: <url }).
            then(function (response) {

                console.log(response.data);
                return response.data;
            }, function (response) {

        });
    };
}
])

Any suggestions would be greatly appreciated.

1
  • 3
    try this $scope.makeCall= function () { ... Commented Mar 23, 2016 at 20:35

1 Answer 1

16

Remove $http parameter from makeCall function, which is killing the existence of $http dependency injected over controller. Basically when you are adding it on function, it is setted as undefined

$scope.makeCall= function () { //<-- removed $http dependency from here
   console.log("HERE");
   $http({ method: 'GET', url: 'url' })
      .then(function (response) {
            console.log(response.data);
            return response.data;
      }, function (response) {

      }
   );
};
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.