0

------- Edited question -----

I need use orderBy with limitTo:

example:

orderBy id limitTo 1

'adam1@xxx' - id:10

'adam2@xxx' - id:20

'adam3@xx' - id:16

after I need order by id again

'adam1@xxx' - id:10

'adam3@xx' - id:16

'adam2@xxx' - id:20

http://jsfiddle.net/WRtqV/924/

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>
Franz
  • 7
  • 2

1 Answers1

0

try the code below: it sort by id and then by code in priority:

<div ng-repeat="item in itemsMsg | orderBy:['id','code']"></div>