Sunday, May 19, 2024
 Popular · Latest · Hot · Upcoming
141
rated 0 times [  142] [ 1]  / answers: 1 / hits: 26846  / 11 Years ago, mon, november 11, 2013, 12:00:00

I am looking for a way to bind data from a three dimensional array in the scope with my view..



My scope (short version) looks like this



$scope.publicationData = [ 
{ pubId:'1' , pubName:'Level 1 A' , pubCat:[
{ pubCatId:'1' , pubCatName:'Level 2 A', pubSubCat:[
{ pubSubCatId:'1' , pubSubCatName:'Level 3 A' },
{ pubSubCatId:'2' , pubSubCatName:'Level 3 B' }
]
},
{ pubCatId:'2' , pubCatName:'Level 2 B', pubSubCat:[
{ pubSubCatId:'3' , pubSubCatName:'Level 3 C' },
{ pubSubCatId:'4' , pubSubCatName:'Level 3 D' }
]
}
]
}];


In the view I have code that successfully presents what is in the first and second array dimension,, but I can't get values from pubSubCatId or pubSubCatName



HTML + Angular View



<div ng-controller=myPublictionCtrl>

<div ng-repeat=publication in publicationData>

<ul>
<li >
<!-- This works -->
{{publication.pubId}}. {{publication.pubName}}
</li>
</ul>

<ul>
<!-- This works -->

<li ng-repeat=category in publication.pubCat>
{{category.pubCatId}}. {{category.pubCatName}}
</li>

</ul>

<ul>
<!-- This doesn't work -->

<li ng-repeat=subcategory in publication.pubCat.pubSubCat>
{{subcategory.pubSubCatName}}
</li>
</ul>
</div>
</div>


How would I retrieve data from deeper layers of the scope. Can AngularJS do this?


More From » arrays

 Answers
8

The third loop must be nested inside the second one, and use



subcategory in category.pubSubCat

[#74342] Monday, November 11, 2013, 11 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
haylie

Total Points: 26
Total Questions: 108
Total Answers: 104

Location: France
Member since Thu, Oct 27, 2022
2 Years ago
;