------- Updated query -----
I am struggling with implementing the orderBy function along with limitTo:
Here is an example:
orderBy id limitTo 1
'adam1@xxx' - id:10
'adam2@xxx' - id:20
'adam3@xx' - id:16
Then, I need to reorder by id again:
'adam1@xxx' - id:10
'adam3@xx' - id:16
'adam2@xxx' - id:20
function MyCtrl($scope) {
$scope.limit = 1;
$scope.itemsMsg = [
{
'adam1@xxx': [{
id: 10,
content: 'test1',
cod: 25
}, {
id: 11,
content: 'test2',
cod: 13
}, {
id: 12,
content: 'test3',
cod: 10
}]
}, {
'adam2@xxx': [{
id: 20,
content: 'test4',
cod: 24
}, {
id: 21,
content: 'test5',
cod: 23
}, {
id: 30,
content: 'test6',
cod: 20
}]
}, {
'adam3@xx': [{
id: 16,
content: 'xxx',
cod: 1
}]
}];
}
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<div ng-app ng-controller="MyCtrl">
<div ng-repeat="item in itemsMsg">
<ul ng-repeat="(key, value) in item">
<li ng-repeat="obj in value | orderBy:id | limitTo: limit">{{obj.id}} :{{obj.cod}} : {{obj.content}}</li>
</ul>
</div>
</div>