Is it possible to customize the number of items displayed from a JSON file using ng-repeat in AngularJS? Currently, it only shows the last item.
JSON Data
{
"list":{
"item1": {
"id":1,
"img": "1.jpg",
"user": "David Belle",
"text": "Cum sociis natoque penatibus et magnis dis parturient montes"
},
"item2": {
"id":2,
"img": "2.jpg",
"user": "Jonathan Morris",
"text": "Nunc quis diam diamurabitur at dolor elementum, dictum turpis vel"
},
"item3": {
"id":3,
"img": "3.jpg",
"user": "Fredric Mitchell Jr",
"text": "Phasellus a ante et est ornare accumsan at vel magnauis blandit turpis at augue ultricies"
}
}
}
AngularJS Configuration
Controller
app.controller('mainCtrl', ['$scope', '$resource', function($scope, $resource) {
$scope.msAPI = $resource("data/messages-notifications.json");
$scope.msResult = $scope.msAPI.get();
}]);
HTML Code
<div ng-controller="mainCtrl">
<a href="" ng-repeat="(key, value) in msResult.list" ng-if="$index < 2">
<div class="lv-title">{{ value.user }}</div>
<small class="lv-small">{{ value.text }}</small>
</a>
</div>