0

I have an angular resource configured as follows:

var resource = $resource('/api', {}, {
        get: {
           ....
        },
        ...,
        submit: {
            method: 'POST',
            params: {
                test: true
            }
        }

Now, when I call submit I would like the url to look like

/api?test=true

However, what I have not doesn't do that, the parameter is ignored. So the question is how do I add this default query param for my submit action ?

1

2 Answers 2

1

$resource supports path params as in the example:

var CreditCard = $resource('/user/:userId/card/:cardId',
  {userId:123, cardId:'@id'},
  {charge: {method:'POST', params:{charge:true}}
});

Use this pattern instead of query parameters.

Sign up to request clarification or add additional context in comments.

Comments

1

Try this:

var resource = $resource('/api?test=:test', {}, {
        get: {
           ....
        },
        ...,
        submit: {
            method: 'POST',
            params: {
                test: true
            }
        }

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.