You should remap your data, in order to achieve your desired output
model should be like this
[{
name: string,
position: number,
titles: string[]
}]
To achieve that do it like this
$scope.items = {
books: [
{ position: 1 },
{ title: 'Harry Potter' },
{ title: 'Lord of The Rings' }
],
movies: [
{ position: 0 },
{ title: 'Mission Impossible' },
{ title: 'Star Wars' }
]
};
$scope.final = [];
_init();
function _init() {
$scope.final = [];
//Iterate the keys
for (var x in $scope.items) {
var data = {
name: x,//store the key in the name
position: $scope.items[x][0].position,//position
titles: []
}
//iterate every item
for (var y of $scope.items[x]) {
//push only the title items
if (y.hasOwnProperty("title")) {
data.titles.push(y.title);
}
}
$scope.final.push(data);
}
console.log($scope.final)
}
In the view should be like this
<div class="item" ng-repeat="item in final | orderBy:'position'">
{{item.name}}
<ul>
<li ng-repeat="title in item.titles">
{{title}}
</li>
</ul>
</div>