I am new to AngularJs . I want repeated UL and each UL having two LI . In Model, I have array of Customer Object.
Customers =[{Customer:1},{Customer:2},{Customer:3},{Customer:4},{Customer:5}];
In View I want like below,
<ul><li>1</li><li>2</li></ul>
<ul><li>3</li><li>4</li></ul>
<ul><li>5</li></ul>
There you go: http://jsfiddle.net/F45Db/
<ul ng-repeat="c in dummy track by $index" ng-class="{last: $last}">
<li ng-repeat="cust in Customers"
ng-if="$index >= $parent.$index*2 && $index < $parent.$index*2 + 2">
{{cust.Customer}}
</li>
</ul>
js:
function Controller($scope){
$scope.Customers = [{Customer:1},{Customer:2},{Customer:3},{Customer:4},{Customer:5}];
$scope.$watchCollection('Customers', function(){
if($scope.Customers.length){
$scope.dummy = new Array(Math.ceil($scope.Customers.length/2));
}
});
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With