AngularJs ReferenceError: $http is not defined

I have the following angular function

$scope.updateStatus = function(user){    
 $http({
  url: user.update_path, 
  method: "POST",
  data: {user_id: user.id, draft: true}
 });
};

But whenever this function is called, I am getting the ReferenceError: $http is not defined in my console. Can anyone help me understand what i am doing wrong here.

Probably you haven't injected $http service to your controller. There are several ways of doing that.

Please read this reference about DI. Then it gets very simple:

function MyController($scope, $http) {
   // ... your code
}

I have gone through the same problem when I was using

    myApp.controller('mainController', ['$scope', function($scope,) {
        //$http was not working in this
    }]);

I have changed the above code to given below. Remember to include $http(2 times) as given below.

 myApp.controller('mainController', ['$scope','$http', function($scope,$http) {
      //$http is working in this
 }]);

and It has worked well.