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

前端 未结 26 3534
刺人心
刺人心 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:19

    You can use this example.

    Inside controller:

    $scope.data = {
        'myVal': 33,
        'maxVal': 55,
        'indexCount': function(count) {
            var cnt = 10;
            if (typeof count === 'number') {
                cnt = count;
            }
            return new Array(cnt);
        }
    };
    

    Example for select element at the HTML code side:

    
    

提交回复
热议问题