javascript - $http is not a function in link functions of directive -


i new angular js , trying use directives. want use $http in link function of directive. below code

myapp.directive('appitem', ['$http',function() {    return {      restrict: 'e',      scope: {        transaction: '='      },      templateurl: 'js/directives/appitem.html' ,      link: function($scope, $http, element, attrs) {             $scope.process = function(trid) {                $http({                     method: 'patch',                     url: 'http://myapp.domain.local/api/v1/items/'+trid+'.json'                 }).                then(function successcallback(response) {                 console.log(response);                });             }         }    } }]); 

but gives me error:

$http not function 

myapp.directive('appitem', ['$http',function($http) {     return {       restrict: 'e',       scope: {         transaction: '='       },       templateurl: 'js/directives/appitem.html' ,        link: function(scope,element, attrs) {              scope.process = function(trid) {                 $http({                      method: 'patch',                      url: 'http://myapp.domain.local/api/v1/items/'+trid+'.json'                  }).                 then(function successcallback(response) {                  console.log(response);                 });              }          }      }  }]);


Comments