Confused on how to send custom parameters to a method. I've done this:
.factory('OrdersFactory', ['$resource', 'baseUrl', function ($resource, baseUrl) {
var actionUrl = baseUrl + 'orders/';
return $resource(actionUrl + ':id', {
id: '@id'
}, {
visual: {
method: 'GET',
url: actionUrl + 'visualOrders/:completed/:date',
responseType: 'json'
}
}
}]);
So my default query() gets all my orders, but now I want another method called visual
where I specify a completed
and a month
parameter, and then it calls the URL indicated.
In my controller, I've imported the OrdersFactory and am using it just fine, but can't get the syntax right to call this visual
query.
I'm wanting to do something like
$completed = OrdersFactory.visual(true, '2013-08-01');
Angular needs to know how your params map to your url templating. One way is to pass your params as an object (i.e, key : value)
$completed = OrdersFactory.visual({completed: true, date: '2013-08-01'});