Tag Archives: range

AngularJS Ng-Repeat In Range

AngularJS does not provide a way to create multiple copies of an element.

Still this behavior is easy to achieve. Check the bellow filter which solves this problem:

'use strict';

angular
.module('APP')
.filter('range', function() {
    return function(input, total) {
        total = parseInt(total, 10);

        for(var i=0; i<total; ++i) {
            input.push(i);
        }
    
        return input;
    };
})

;

Usage:

<div ng-repeat="n in [] | range:10">element copy #{{$index}}/10</div>