的链接函数中的函数我是新来的角js和尝试使用指令。 我想在指令的链接函数中使用$ http。 下面是我的代码
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);
});
}
}
}
}]);
但它给我的错误:
$http is not a function
更新您的代码 – saikumar