-2

I keep getting this error even though i injected $http in my controller.

app.controller('myCtrl', ['$scope', '$http', function($scope, $http) {
    $scope.user = {
        name: '',
        address: '',
        email: '',
        date: '',
        time: '',
        phone: '',
        zipcode: 0,
    };
}]);

and when i try to post an httprequest on this code

$scope.reserve = function() {
   $http.post('/user'
       $scope.user).success(function(response) {
       console.log(response);
   });
}

It is giving me $http is not defined error.

Flying Gambit
  • 1,238
  • 1
  • 15
  • 32
Abdi
  • 1,298
  • 1
  • 9
  • 10
  • 1
    Are you refering to $http inside the controller function? Also there seems to be a missing comma after '/user'. – Luka Jacobowitz Feb 01 '16 at 11:53
  • 1
    If `myCtrl` literally is defined as above, then of course it has nothing to do with that other code snippet, because the controller is defined as an empty function. **What exactly is the relationship between those two pieces of code?** – deceze Feb 01 '16 at 11:53

1 Answers1

1

You are terminating your function in

function($scope, $http){}

You should write your controller's code within the function.

matanso
  • 1,284
  • 1
  • 10
  • 17