1

I'm trying to do a ng-repeat over a json array. I'm able to do the first iteration of 'event in calendar'. But I'd not have to manually iterate through each number. This works:

<div ng-repeat="event in calendar">
          {{event[0].custom_fields.location[0]}}
          {{event[0].custom_fields.price[0]}}
          {{event[1].custom_fields.location[0]}}
          {{event[1].custom_fields.price[0]}}  
          {{event[2].custom_fields.location[0]}}
          {{event[2].custom_fields.price[0]}}        
</div>

I've tired doing two ng-repeats and it fails. How do I fix this?

<div ng-repeat="event in calendar">
          <div ng-repeat="custom_fields in event.custom_fields">
             {{custom_fields.location[0]}}
             {{custom_fields.price[0]}}
          </div>
</div>
1
  • Can you create a JSFiddle or codepen? Commented Oct 11, 2015 at 4:25

1 Answer 1

3

According to your first example, event is the array, not the custom_fields property. Iterate it instead.

<div ng-repeat="events in calendar">
    <div ng-repeat="event in events">
        {{event.custom_fields.location[0]}}
        {{event.custom_fields.price[0]}}
     </div>
</div>
Sign up to request clarification or add additional context in comments.

2 Comments

I dont have "events", only "event"
@SeanWinkler You're misunderstanding how the locally scoped variables will work. events is just a variable created to hold the result of the calendar iterations.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.