Within my JSON file, I have the following simple structure:
{"Item1": {"p1": {"p1sub1": 8, "p1sub2": 7}, "p2": {"p2sub1": 6, "p2sub2": 5} },
"Item2": {"p1": {"p1sub1": 4, "p1sub2": 3}, "p2": {"p2sub1": 2, "p2sub2": 1} } }
To retrieve this data, I use the code below:
app.controller('customersCtrl', function($scope, $http) {
$http.get("content2.json")
.success(function (data) {$scope.items = data;});
});
The retrieved data is then displayed in HTML as follows:
<ul ng-repeat="(i, val) in items | orderBy:'p1.p1sub1'">
<li>{{i}} - {{val.p1.p1sub1}} - {{val.p1.p1sub2}} - {{val.p2.p2sub1}} - {{val.p2.p2sub2}}</li>
</ul>
Regardless of what parameter is used in the "orderBy" filter, the output remains the same:
Item1 - 8 - 7 - 6 - 5
Item2 - 4 - 3 - 2 - 1
Is there a method to sort the list based on the 'p1.p1sub1' values?
Edit: My objective is to arrange the rows in ascending or descending order based on the values of p1.subp1. For example: Ascending
Item2 - 4 - 3 - 2 - 1
Item1 - 8 - 7 - 6 - 5
Descending
Item1 - 8 - 7 - 6 - 5
Item2 - 4 - 3 - 2 - 1
This is just a small preview, with the final file containing numerous items to be sorted.