Way to ng-repeat defined number of times instead of repeating over array?

前端 未结 26 3561
刺人心
刺人心 2020-11-22 14:53

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

26条回答
  •  不要未来只要你来
    2020-11-22 15:39

    I am creating a reusable directive where the max number will come from another ng-repeat. So, this is an edit over the best voted answer.

    Just change the code at controller to this -

    $scope.getNumber = function(num) {
        var temp = [];
        for(var j = 0; j < num; j++){
            temp.push(j)
        }
        return temp; 
    }
    

    This will return a new array with specified number of iterations

提交回复
热议问题