0
我有這個http請求,工作正常。
控制器
$scope.removeRow = function (od){
var temp = "order_id=" + od.order_id + "&product_id=" + od.product_id + "&variant_id=" + od.varient_id;
var req = $http({
method: 'POST',
url: 'http://<domain name>/api2/v1/delete_item_in_order',
data: temp,
headers: {'Content-Type': 'application/x-www-form-urlencoded'}
});
req.then(
function (response) {
alert('success')
},
function (error) {
//$scope.details = response.data;
alert(error.message);
}
);
}
服務代碼來獲取資源對象:
sampleApp.factory('Order', function ($resource) {
return $resource('http://<domain name>/api2/v1/orders/:id', {id: '@_id'}, {
'get': {method:'GET'}
});
});
問題
如何添加自定義的方法removeRow
在Order
Servi大街ce,這樣我可以使用$resource
而不是$http
in $scope.removeRow()
in controller?
在這裏看到我的回答(http://stackoverflow.com/questions/36310771/get-data-on-conditions-by-resource -angualrjs/36311255#36311255) –