Handling $resource object parameter

Having the following $resource service:

myService.factory('Phones', function ($resource) {
    return $resource('/api/Phones', { phoneName: '@phoneName' }, {
        submit: { method: 'POST', },
    });
});

Calling submit on the returned $resource object will post the phoneName as a parameter e.g. /api/Phones?phoneName=Nokia. However calling the same resource object with the GET method will also use the phoneName parameter as undefined e.g. /api/Phones?phoneName=undefined.

Is it possible to prevent the phoneName to appear for the GET method using the same $resource object?

Thanks!

Try changing your service to this:

myService.factory('Phones', function ($resource) {
    return $resource('/api/Phones', {}, {
        submit: { 
          method: 'POST'
        }
    });
});

That way you only define the paramater 'phoneName' on the 'submit' action and not all actions.

Edit: You don't need to define phoneName as a param in the $resource action.