Nested Angular JS http.json


#1

Hi!

I have to json I need to get from a wordpress site(events and featured image).
In it’s simples form it looks like this:

event=http.json
for i++ event.length{
image=http.json (imageID=event.imageID)
postlist.push title=event.title, imageURL=image.imageURL
}

But this does not work. All I get is a promise.
Please help!!!


#2

Your question doesn’t clarify anything. just assuming http.json is a method to call a service

var eventPromise = http.json('event');   //event will be a promise
eventPromise.then(function(data) {
//assuming dasta will contain all events
   var postList = [];
    angular.forEach(data,function(event) {
         http.json('image/event.ID').then(function(img) {
             postlist.push({title:ebent.title,imageURL:img.url});
         });
    });
});