Angularjs PATCH-undefined不是函数

Angularjs PATCH - undefined is not a function

本文关键字:函数 PATCH-undefined Angularjs      更新时间:2023-09-26

我正在尝试使用angular$http.patch()函数来调用API URl正如这些答案1和2所建议的那样,我在配置中将Content-Type头设置为application/json。

但我仍然得到错误:

undefined不是函数

我在这里错过了什么?以下是出现错误的代码(注意:我在服务中注入了$http,其他方法GET、POST、PUT、DELETE都很好):

deleteAll: function (data) { // custom service function
                url = $rootScope.config.api.stack.add_stack;                
                return $http.patch(url,angular.toJson(data)); // error thrown here in firebug
            }

AngularJs版本:v1.2.16

即使我尝试过使用最新的angularjs版本,但它仍然没有让惊叹

<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>

$http中没有补丁方法。将$http与配置一起使用

$http({ method: 'PATCH', url: url, data: angular.toJson(data));

最新消息:卢卡斯下面的回答现在更具相关性。

现在有一种方法:AngularJs Docs