What is a clean way to send a body with DELETE request? What is a clean way to send a body with DELETE request? angularjs angularjs

What is a clean way to send a body with DELETE request?


This works.

$scope.delete = function(object) {    $http({        url: 'domain/resource',        method: 'DELETE',        data: {            id: object.id        },        headers: {            "Content-Type": "application/json;charset=utf-8"        }    }).then(function(res) {        console.log(res.data);    }, function(error) {        console.log(error);    });};


You can inject the $http (http://docs.angularjs.org/api/ng.%24http#Usage) component into one of one of your controllers and by using it as follows :

$http({method: 'DELETE', url: 'www.url.com', headers: {'X-MY-HEADER': 'MY_VALUE'}});

I hope this what you expected.


You should be able to call 'remove' on your resource as explained in the documentation https://docs.angularjs.org/api/ngResource/service/$resource