angularjs - Mapping array items to repeated list -


here's unsophisticated version of want achieve:

$scope.colors = [{ "name": "red" },{ "name": "orange" },{ "name": "yellow" }];  <ul>     <li>{{colors[0].name}}</li>     <li>{{colors[1].name}}</li>     <li>{{colors[2].name}}</li>     <li></li>     <li></li> </ul> 

but i'd more dynamically. is, repeat 5 list items each containing item array colors may contain 5 items (in case 3).

you way span here..

   <ul>         <li ng-repeat="i in [1,2,3,4,5]">           <span ng-if="i<=colors.length">{{colors[i].name}}</span>          </li>     </ul> 

Comments

Popular posts from this blog

c++ - Delete matches in OpenCV (Keypoints and descriptors) -

java - Could not locate OpenAL library -

sorting - opencl Bitonic sort with 64 bits keys -