AngularJs ReferenceError: $http is not defined

前端 未结 3 1228
不思量自难忘°
不思量自难忘° 2020-11-29 21:22

I have the following Angular function:

$scope.updateStatus = function(user) {    
    $http({
        url: user.update_path, 
        method: \"POST\",
              


        
3条回答
  •  感情败类
    2020-11-29 22:00

    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.

提交回复
热议问题