Tuesday, 15 May 2012

javascript - AngularJS resource factory always returns empty response -


OK, so I think I'm missing a few basic things here, but I'm reading docs and other examples. Did not understand I have a resource in this type of factory:

  loteManager.factory ('Lotes', function ($ resource) {return $ resource ('./api/lotes/: id', {Id: "@ id"}, {get: {method: 'GET', isArray: true}})}}   

and my controller:

  loteManager.controller ('LoteCtrl', function InfoCtrl ($ scope, $ routeParams, Lotes) {Lotes.get (feedback) {console.log (response);});});  < / Pre> 

When I define the ID manually such as this $ resource ('./api/lotes/21' ), I think the problem ID is going through Of On the eve I tried to add the first parameters: {id: "@ id"} , but that too was not working.

  loteManager.controller ('LoteCtrl')  , Function InfoCtrl ($ radius, $ route param, lots) {Lotes.get ({id: $ routeParams.loteId}, function (feedback) {console.log (response);});});   

... assuming you have a defined path like this:

  $ routeProvider.when ('/ somepath /: loteId, { TemplateUrl: 'sometemplate.html', Controller: LoteCtrl});   

To:

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

No comments:

Post a Comment