I am new to angularJS.
I want to iterate for loop.
Here is my try,
totalDays = 4;
<tr ng-repeat="key in totalDays">
...
</tr>
But i can't able to loop.
Thanks in advance.
I am new to angularJS.
I want to iterate for loop.
Here is my try,
totalDays = 4;
<tr ng-repeat="key in totalDays">
...
</tr>
But i can't able to loop.
Thanks in advance.
You need to pass the number to a function and generate an array as follows,
$scope.getDays = function(num) {
return new Array(num);
}
DEMO
var app = angular.module('myapp',[]);
app.controller('personController',function($scope){
$scope.totalDays = 4;
$scope.getDays = function(num) {
return new Array(num);
}
});
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<div ng-app = "myapp" ng-controller = "personController">
<ul>
<li ng-repeat="i in getDays(totalDays) track by $index"><span>{{$index+1}}</span></li>
</ul>
</div>