patch-Anforderung mit angularjs

Arbeite ich an einer API mithilfe von djang-tastypie als backend und AngularJs für front-end. Ich sende Anfrage her CRUD mit angularjs $http. GET, POST, PUT alles in Ordnung ist, aber wenn ich bin versucht, senden Sie eine PATCH-Anforderung es ist PATCH-error " - Methode ist nicht definiert. Ich habe eine Fabrik der api-Aufrufe in eckig aber PATCH-Anforderung ist der dort nicht arbeitet.

angular.module('tastypieModule', ['ngResource']).
factory('apiCall', function($http, $resource) {

    delete $http.defaults.headers.common['X-Requested-With'];

    var apiCall = $resource('/api/v1/:type/:id/',
        {type: '@type', username: '@userName', api_key: '@api_key', user: '@userID', id: '@id'},
        {
            get: {method: 'GET'},
            post: {method: 'POST', headers: {'Content-Type': 'application/json'}},
            del: {method: 'DELETE', headers: {'Content-Type': 'application/json'}},
            update: {method: 'PUT', headers: {'Content-Type': 'application/json'}},
            pupdate:{method:'PATCH',headers: {'Content-Type': 'application/json'}}
        }
    );

 return apiCall;
});  
 function MyCtrl($scope,$resource){
$scope.edit=function(){
   id=$scope.E_id
    $http.pupdate('/api/v1/quizsetting/'+id+'/', editedquizsetting).
    success(function(data, status) {
        $scope.status = status;
        $scope.data = data;
        $scope.editQuizSettingModal = false;
        //$scope.quizsettinglist.objects[$scope.e_quizsettingindex]=data;
        $(".message").append("object has been created successfully");
    })
    .
     error(function(data, status) {
        $scope.data = data || "Request failed";
        $scope.status = status;        
    });
};
}

dies ist mein HTML-code

<div ng-app="myApp">
<div ng-controller="MyCtrl">
<button type="button" ng-click="edit()">Edit</button>
</div></div>

wenn ich senden einer Pfad-Anfrage mit diesem code in der Konsole zeigt er http.patch ist nicht eine Funktion.
Sag mir, wie kann ich konfigurieren ng-app-und services zum senden einer PATCH-Anforderung Verwendung von angularjs.

InformationsquelleAutor Sarfraz Ahmad | 2013-11-15

Schreibe einen Kommentar