1

I want to display data in ul / li so I am fetching it through loop in my html like :

I have two array where :

  $mainarray = [{"Name":"data1","count":9},{"Name":"data2","count":10},
 {"Name":"data3","count":4},{"Name":"4","count":20}];


 $color = ['red','pink','green','yellow','black'];
 $color = ['red','pink','green','yellow','black'];

I am looping through main array like this and its working fine :

<ul style="list-style-type:circle; padding: 0px !important; font-size:22px;">
<li ng-repeat="item in mainarray " style="margin-bottom: 10px;"; >
    <span style=" font-size: 16px; ">{{ item.name }}</span>
</li>
</ul>

However, I want to add $color with this like :

for data1 -> red
data2->pink 
and so on ....

I have tried with multiple loop but its not working !

Any clues ?

gurvinder372
  • 66,980
  • 10
  • 72
  • 94
CodeWithCoffee
  • 1,896
  • 2
  • 14
  • 36
  • Possible duplicate of [looping multiple arrays simultaneously with ng-repeat](https://stackoverflow.com/questions/30846032/looping-multiple-arrays-simultaneously-with-ng-repeat) – Jigar Shah Jan 31 '18 at 05:44

1 Answers1

1

Your can use $index

<span style=" font-size: 16px; ">{{ item.name }} -> {{ color[$index] }}</span>
gurvinder372
  • 66,980
  • 10
  • 72
  • 94