How to get the index of an parent scope array/ng-repeat inside child ng-repeat

后端 未结 3 401
广开言路
广开言路 2021-01-28 09:53

I am building a table and I have two ng-repeat for my table.

My question is if it\'s possible the child of the ng-repeat can get the parent

3条回答
  •  旧时难觅i
    2021-01-28 10:09

    Using $parent can get you the parent scope's original array. From there, the array indexOf() function will get you the index of the element with respect to its array. In your code it looks like this

    
        
            company # = {{$parent.companies.indexOf(company)}} and product {{$index}}
        
    
    

提交回复
热议问题