0

All,

I'm having some trouble with $resource calls in my angularjs app. I've spent a couple of days looking for answers and from what I can see my code should work but it just doesn't. I would be truly grateful if anyone could explain to me what the problem is with the following code (which is executed in a controller).

var Comp = $resource('http://localhost:8081/my-rest-ws/webapi/company/:id', {id: '@id'});
$scope.company = Comp.get({id: 1}, function() {
  console.log('got it');
});

When I inspect the URL in the dev console it looks as follows:

URL:http://localhost:8081/motrev-rest-ws/webapi/company/:id/[object%20Object]<br>

It was my understanding that the id parameter should be replaced by the value (1 in my case) but clearly that doesn't happen. So, what am I doing wrong?

Thanks in advance
Daniel Södling

Tim
  • 41,901
  • 18
  • 127
  • 145
  • It seems to work fine for me: http://jsfiddle.net/ExpertSystem/F6hxV/ – gkalpak May 12 '14 at 10:36
  • That is so strange. The fiddle does indeed work just as you say (also for the query function which I also had problems with). Could it possibly be some sort of conflict between different modules? I'm using ui-router as well. – Daniel Södling May 12 '14 at 10:59
  • No idea. Could you prepare an **[SSCCE](http://sscce.org)** ? – gkalpak May 12 '14 at 11:18
  • Sure, I'll try to sort one out tonight. Thanks for helping out. – Daniel Södling May 12 '14 at 11:41
  • So.... funny story... It turns out that if you actually include _angular-resource_ and not _ng-resource_ things work just as they do in your jsfiddle and also just as they do in the documentation. My apologies for wasting your time. – Daniel Södling May 12 '14 at 18:34

0 Answers0