from the documentation (http://docs.angularjs.org/api/ngResource.$resource):
$resource(url[, paramDefaults][, actions]);
paramDefaults(optional) – {Object=} – Default values for url parameters.
…
If the parameter value is prefixed with @ then the value of that parameter is extracted from the data object.
The question is what data object do they refer to? How to use this feature?
lets say you have a resource like this:
It means that the value of
:userIdin your url will be replaced with theidproperty from the user object when that property is required.So when is it required? Its required when you are doing something to an existing user, like
geting one, updating one. It is not required when you create a user.In most cases, you will want to have at least one param prefixed with @ in your REST url that resource uses (probably the object id). If you dont have one, that means that in order for you to save an instance of an object, you dont need to know anything about where its stored. This implies that its a singleton object. Maybe like a settings object.
Here is your long awaited example:
will produce the request: GET
/user/123/Matt