Skip to content

AngularJS ng-repeat limitTo with Objects

<div ng-repeat="(key, value) in object | limitTo: 2">

will not work, as ngRepeat needs a string or an array to work with. A workaround is to use ng-if="$index < 2".

<div ng-repeat="(key, value) in object" ng-if="$index < 2">

Do note that the order of keys for any given object may vary.