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
Post a Comment