Znowman Znowman - 1 year ago 163
AngularJS Question

Limit array, angular

Trying to limit the output from an array. list is the array in the data object.

<tr ng-repeat="item in data.list" ng-if=""><td>{{item.data.attribute}}</td></tr>

Is it possible to do with ng-repeat?

Answer Source

First thing remove ng-if. Then use limitTo filter provided by angular out of the box.

ng-repeat="item in data.list | limitTo: 4 as filtered"

You could use the same filter inside controller as well.

var limit = 5;
$scope.filteredData = $filter('limitTo')($scope.data.list)(limit);
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download