Struggling to sort a nested 2D Array using AngularJS filters? I could use some help with this complex task. Any assistance would be greatly appreciated. Thank you!
I currently have a 2D Array and need guidance on how to sort it within an ng-repeat loop.
Here is the code snippet from the template file...
<ul>
<span ng-repeat="list in lists">
<li ng-repeat="list_ in list.list1 | orderBy:'name'">{{list_.name}}</li>
</span>
</ul>
And here is the corresponding JavaScript code...
$scope.lists = [
{
no : 1,
list1 : [{
name : 'A'
},
{
name : 'M'
}]},
{
no : 2,
list1 : [{
name : 'B'
}]},
{
no : 5,
list1 : [{
name : 'Z'
}]},
{
no : 3,
list1 : [{
name : 'X'
},
{
name : 'T'
}]}
]
For further reference, please check out the plunker here.