1

This is from the documentation.

var User = $resource('/user/:userId', {userId:'@id'});
var user = User.get({userId:123}, function() {
  user.abc = true;
  user.$save();
});

What does @id mean? If we are supposed to supply userId as an argument as specified by /:userId, why specifying this rule again in {userId: '@id'}, assuming that's what it means.

Lim H.
  • 9,870
  • 9
  • 48
  • 74
  • possible duplicate of [AngularJS $resource @ prefixed parameter](http://stackoverflow.com/questions/13187823/angularjs-resource-prefixed-parameter) – Lim H. Nov 14 '13 at 19:06
  • Read this post http://stackoverflow.com/questions/13313971/at-sign-in-parameter-names-in-resource-definition – Rob Nov 14 '13 at 19:09

1 Answers1

1

It means that the :userId will be removed from url if not present on the $resource call, as written in docs:

If the parameter value is prefixed with @ then the value of that parameter is extracted from the data object (useful for non-GET operations).

Beterraba
  • 6,515
  • 1
  • 26
  • 33
  • Sorry I have been working non stop for 24+ hrs. For the love of God, I didn't either see this line in the documentation and the SO question which asks the same thing. Thanks anyway. – Lim H. Nov 14 '13 at 19:06