Is there a way to ng-repeat a defined number of times instead of always having to iterate over an array?
For example, below I want the list item to show
Angular provides filters to modify a collection. In this case the collection would be null, i.e. [], and the filter also takes arguments, as follows:
- {{$index}}
JS:
module.filter('fixedNumber', function() {
return function(emptyarray, number) {
return Array(number);
}
});
module.controller('myCtrl', ['$scope', function($scope) {
$scope.number = 5;
}]);
This method is very similar to those proposed above and isn't necessarily superior but shows the power of filters in AngularJS.