最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Angularjs PATCH - undefined is not a function - Stack Overflow

programmeradmin4浏览0评论

I am trying to use angular $http.patch() function to call a API URl As recommended by these answers - 1 and 2 i have set Content-Type headers to application/json in the config.

But still i get the error:

undefined is not a function

I am missing here something? Below is my code where the error is throwing up (Note: I have injected $http in my service and other methods GET,POST,PUT,DELETE are working fine):

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 version: v1.2.16

Even i tried using the latest angularjs version but still its not woking

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

I am trying to use angular $http.patch() function to call a API URl As recommended by these answers - 1 and 2 i have set Content-Type headers to application/json in the config.

But still i get the error:

undefined is not a function

I am missing here something? Below is my code where the error is throwing up (Note: I have injected $http in my service and other methods GET,POST,PUT,DELETE are working fine):

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 version: v1.2.16

Even i tried using the latest angularjs version but still its not woking

<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
Share Improve this question edited May 23, 2017 at 11:45 CommunityBot 11 silver badge asked Aug 28, 2014 at 9:40 VishwaKumarVishwaKumar 3,4338 gold badges46 silver badges72 bronze badges
Add a comment  | 

2 Answers 2

Reset to default 14

There is no patch method in $http. Use $http with config

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

UPDATE: Lukas's answer below is more relevant for now.

There is a Method now: AngularJs Docs

发布评论

评论列表(0)

  1. 暂无评论