How to repeat elements pulled from an array inside a javascript object literal with ng-repeat

倾然丶 夕夏残阳落幕 提交于 2020-01-06 17:57:48

问题


I'm repeating elements from a big javascript object literal. Currently, I display the tabbed navigation, image, and title for each product correctly. I cannot get the info to display correctly however. I have the following code:

<div ng-repeat="section in tab.sections" class="product">            
    <div  ng-repeat="child in section.children" ng-if="productIsActive(child, $index)">
        <div class="additionalProductInfo">                             
            <nav class="secondaryTabbedNavigation">
                <ul>
                    <li class="active" ng-repeat="pTabs in child.productTabs">
                        <a class="activelink" href="#">{{pTabs.title}}</a>  //title of each tab                 
                    </li>
                </ul>
            </nav>

        </div>

        <div class="productImage">
            <img ng-src="{{ child.productImageURL }}"/> //the product image
        </div>
        <div class="productInfo">
             <h2 class="productTitle">{{ child.title}}</h2> //the product title
             <div ng-repeat="info in pTabs.infoData" class="productDescription">
                 <p>
                    {{info[1]}} //product info goes here. 
                 </p>                                                   
             </div>                           
        </div>              
    </div>    
</div>

I also tried "{{info}}" , "{{info[i][i]}}", and a couple things using $index. But when "{{info}}" didn't display anything, I figured I was retrieving the data incorrectly.

Here is the "tabs" javascript object that all this info comes from:

As you can see the product info is in a two dimensional array (the first array with the labels of what the information is (e.g. "Title", "Link") and the corresponding information is in the second array. I know this may not be ideal, but this information is currently grabbed from .csv files that prone to changing and I cannot change how they come into this javascript object.

I know this may seem overcomplicated but this is about as deep as I need to go to get data from the large javascript object and I'm very close.

How can I get the contents from the second array in the two dimensional array (infoData[1]) to display like I did with the tabs, image, and title.

Thank you very much for your time!

来源:https://stackoverflow.com/questions/28442303/how-to-repeat-elements-pulled-from-an-array-inside-a-javascript-object-literal-w

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!