When working with a simple resource like the one defined below, it is possible to utilize the Receipt.query()
method to retrieve a collection from the server. In addition, by calling
Receipt.query({freightBill: 123})
, a query parameter such as freightBill can be added to the request URL like so: /distribution/inbound?freightBill=123
. How can I include query parameters in this manner, while also setting default values for page, size, and sort within my factory?
The resulting request would appear something like
/distribution/inbound?freightBill=123&page=0&size=20&sort=number,desc
angular.module('webappApp')
.factory('receipts', function ($http, $resource, $location) {
var search = $location.search();
var page = search.page||0;
var size = search.size||20;
var sort = search.sort||'number,desc';
return $resource('/distribution/inbound');
});