app.factory('PartnerServiceRestangular', ['Restangular', function(Restangular) {
return Restangular.service('partner');
}]);
app.factory('PartnerInvoiceServiceRestangular', ['PartnerServiceRestangular', function(PartnerServiceRestangular) {
return PartnerServiceRestangular.one('partner', partnerId).service('invoice');
}]);
我的控制器
app.controller('FinancialsController', [
'$scope',
'PartnerServiceRestangular',
'PartnerInvoiceServiceRestangular',
function($scope, PartnerServiceRestangular, PartnerInvoiceServiceRestangular) {
PartnerServiceRestangular.getList().then(function(partners) {
$scope.partners = partners;
});
$scope.partnerChange = function(partner) {
$scope.partner = partner;
};
var getInvoices = function(partnerId, startDate, stopDate) {
// STUCK HERE
PartnerInvoiceServiceRestangular.get({})
};
我所希望做的是,讓PartnerInvoiceServiceRestangular
執行以下GET請求:
/partner/{partnerId}/invoice/
- 返回特定合作伙伴的所有發票Id/partner/{partnerId}/invoice/?startDate=2014-06-01&stopDate=2014-6-30
- 返回所有發票2個指定的日期 之間
/partner/{partnerId}/invoice/{invoiceId}
- 要返回一個特定發票
我已經在裏面設置的partnerId
在$範圍,startDate
視圖的NG-模式設置,stopDate