In my data set, there is an array of objects referred to as $scope.segments
, which looks like this:
[
{
"_id": "55d1167655745c8d3679cdb5",
"job_id": "55d0a6feab0332116d74b253",
"status": "available",
"sequence": 1,
"body_original": "Such a fork",
"__v": 0,
"body_translated": "Tal bifurcación"
},
{
"_id": "55d1167655745c8d3679cdb4",
"job_id": "55d0a6feab0332116d74b253",
"status": "available",
"sequence": 0,
"body_original": "So this is it.",
"__v": 0,
"body_translated": "Así que esto es."
}
]
To rearrange this array based on the 'sequence' property in ascending order (starting with sequence 0), I am using the following code snippet inside a view:
<ul ng-repeat="segment in segments | orderBy: 'sequence'">
<li>{{ segment.sequence }}</li>
</u>
However, when attempting to apply the orderBy filter within a controller using the code below:
$scope.test = $filter('orderBy')($scope.segments, 'sequence');
The result appears to be an empty array ([]). This suggests that the $filter function may not be functioning properly within the controller.
If you have any suggestions or insights on resolving this issue, I would greatly appreciate your input. Thank you!