I want to nest the parameters sent to the backend server. So far my current resource looks like
angular
.module('myApp.users')
.factory('User', user);
user.$inject = ['$resource'];
function user($resource) {
return $resource('/users.json');
}
In my controller...
var user = new User({name: 'jason', email: 'jason@gmail.com'});
user.$save()
The params sent to my backend server end up looking like
{name: 'jason', email: 'jason@gmail.com'}
Ideally, I want the params sent to the backend server to look like
{user: {name: 'jason', email: 'jason@gmail.com'}}
I know that in the controller I can write
var user = new User({user: {name: 'jason', email: 'jason@gmail.com'}});
However, I don't like that approach. What I want to know is, is there a way to create nested parameters in the User resource and not in the controller. Can the paramsDefault argument help here?