3

Newbie to angularjs.trying to display data from json nested object like this

enter image description here

my html code is

<a rel="extranal" data-val="<%rcds%>" ng-repeat="rcds in rcd" class="international" id="<%rcds.id%>">
<span><img ng-src="<% rcds.routes.subroutes %>"/> <% rcds.subroutes[0].xyz%></span>
<div class="departure-time"><% rcds.subroutes[0].abc %></div>
</a>

want to display the data subroutes in the ng-repeat based on the condition of legtype in the json.how to do this.

2
  • From what I can tell, you have an array of objects in which you have an array called routes, then depart and only then you have the subroutes. If so, in your code you're trying to access subroutes directly on the root object but it can't find it because it's not there, your code should look something like: rcds.routes[0].depart[0].subroutes[0].xyz. On the other hand, you should be able to nest ng-repeats as well.
    – Spluf
    Commented Aug 22, 2016 at 8:40
  • Thanks @Spluf it worked like charm
    – yaswanth
    Commented Aug 22, 2016 at 13:07

1 Answer 1

1

if you want show your object as JSON the only thing that you need is write {{rcds | json}}

Otherwise if you want to navigate your nested object you should do somethings like:

<div ng-repeat="rcds in red">
  <div ng-repeat="route in rcds.routes">

    <!-- route element --->

      <div ng-repeat="depart in route.depart">

        <!-- depart element --->

        <div ng-repeat="subroute in route.subroutes">

          <!-- subroute element -->

        </div>

     </div>

  </div>
</div>

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.