1

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');

1 Answer 1

2

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'});
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.