Recently, I set up a $resource factory like this:
(function() {
'use strict';
app.factory('WidgetFactory', [ '$resource', function($resource) {
return $resource('http://localhost:8282/widget/:widgetId', { widgetId : '@id'},{
rate: {method:'POST', params:{applyRating:true}}
});
}]);
}());
Now, in my controller, I'm trying to retrieve the widget with id 1:
this._widgets = WidgetFactory.get({ id:1 }); // or WidgetFactory.query({ id:1 })
However, the request is sent as
http://localhost:8282/widget?id=1
, when it should be widget/1
.
How can I adjust the request in the $resource from the controller to generate widget/1
? Essentially, how do I utilize the '@id'
parameter within my resource factory (what is the actual functionality of '@id'
)?