Typeerror: $http is not a Function

Asked

Viewed 495 times

0

Script:

app = angular.module("app",[]);

app.controller("controlador", ["$scope", function($scope, $http){
$scope.items = [];

$scope.submitForm = function() {
        // Posting data to php file
        $http({
          method  : 'POST',
          url     : 'http://localhost/nfe/admin/nfephp-master/exemplos/NFe/4.00testaMakeNFe.php',
          data    : $scope.items, //forms user object
          headers : {'Content-Type': 'application/x-www-form-urlencoded'} 
         })
}]);

Form:

<form ng-submit="submitForm()">
 ...
</form>

Error:

inserir a descrição da imagem aqui

What could be causing this error?

1 answer

6


You are missing declare the import of it:

app.controller("controlador", ["$scope", "$http", function($scope, $http){

Browser other questions tagged

You are not signed in. Login or sign up in order to post.