Add repeat-range directive #10925
Description
Programmers want this directive!
Google has many examples with ng-range, ng-repeat-range, but a lot of them working through compiling to e.g ng-repeat="n in [1,2,3,4,5,6]". This may create a large arrays in memory.
I want to see the ng-range directive as:
<div ng-range="5"> {{ n }} </div>
- renders my element 5 times (n is a default alias)
<div ng-range="5 as x"> {{ x }} </div>
- x is an new alias
<div ng-range="1 to 10"> {{ n }} </div>
<div ng-range="1 to 10 as x"> {{ x }} </div>
<div ng-range="10 step 2"> {{ n }} </div>
<div ng-range="10 step 2 as x"> {{ x }} </div>
<div ng-range="1 to 10 step 2"> {{ n }} </div>
<div ng-range="1 to 10 step 2 as x"> {{ x }} </div>
I wrote the RegExp for parse this string.
/^(.+?)(?:\s*to\s*(.+?))?(?:\s*step\s*(.+?))?(?:\s*as\s*(\w+))?$/
.
Thanks!