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

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

    There are many ways to do this. I was really bothered at having the logic in my controller so I created a simple directive to solve the problem of repeating an element n-times.

    Installation:

    The directive can be installed using bower install angular-repeat-n

    Example:

    {{$index}}

    produces: 1234

    It also works using a scope variable:

    
    

    Source:

    Github

提交回复
热议问题