javascript - Spring MVC, AngularJS. Can't hadle object values in JS -


to handle pagination etc decided create object wrapper called apiresponse looks this:

public class apiresponse<t> {      list<t> objectlist;     list<?> nestedelements;     int currentpage;     int offset;  // etc...  } 

in angular have constructed service below:

app.factory('apartment', ['$resource', function ($resource) {      return $resource(             'http://localhost:8080/kamienica/api/v1/apartments/:id.json',              {id: '@id'},             {                 'query':  {method:'get', isarray:false},                 'update': {method: 'put'}              }     ); }]); 

in controller have:

            self.fetchall = function() {                  var res = apartment.query();                  console.log('=====   console.log(res);     =====');                 console.log(res);                  console.log('=====    console.log(res.objectlist);      =========');                 console.log(res.objectlist);               }; 

when print 'res' object correctly if want reach variables 'undefined' can see on screenshot

browser screenshot

previously in spring controller returning list <apartment> instead if apiresponse<apartment> , worked fine.

bottom line how can reach objectlist , other variables stored object?

when call apartment.query(); data fetched server in background. @ time call console.log(res.objectlist); has no property objectlist because data not available yet.


Comments