AngularJS For Loop with Numbers & Ranges. Use the below example if you want to print the numbers and ranges using for loop in AngularJS.
JS Code:
1 2 3 4 5 6 7 8 9 10 11 12 | var myApp = angular.module('myApp', []); myApp.filter('range', function() { return function(input, total) { total = parseInt(total); for (var i=0; i<total; i++) input.push(i); return input; }; }); function Main($scope){ } |
HTML Code:
1 2 3 | <div ng-app='myApp' ng-controller="Main"> <li ng-repeat="n in [] | range:5">test</li> </div> |
If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.