ngOrderObjectBy icon indicating copy to clipboard operation
ngOrderObjectBy copied to clipboard

Orderby Object of Object

Open zachary545 opened this issue 9 years ago • 0 comments

Hi Fabricio, What if my JSON file looks like this:

[
  {
    "id": "61",
    "names": "Test 1",
    "Mon": [
      {
        "1000": "5",
        "waitTime": 5
      },
      {
        "1030": "10",
        "waitTime": 10
      },
      {
        "1100": "15",
        "waitTime": 20
      },
      {
        "1130": "20",
        "waitTime": 30
      },
      {
        "1200": "20",
        "waitTime": 35
      }
    ],
    "Tue": [{}],
    "Wed": [{}],
    "Thur": [{}],
    "Fri": [{}],
    "Sat": [{}],
    "Sun": [{}]
  }
]

My current ng-repeat looks like this: ng-repeat="item in items | orderObjectBy:'items[Day][time].waitTime':false |filter:search"

controller:

$scope.HHmm = $filter('date')(new Date(), 'HHmm');
$scope.Day = $filter('date')(new Date(), 'EEE');

if($scope.HHmm >= 1000 && $scope.HHmm < 1030){
    $scope.time = 0;
    $scope.hours = '1000';
  }
  else if($scope.HHmm >= 1030 && $scope.HHmm < 1100){
    $scope.time = 1;
    $scope.hours = '1030';
  }
  else if($scope.HHmm >= 1100 && $scope.HHmm < 1130){
    $scope.time = 2;
    $scope.hours = '1100';
  }
  else if($scope.HHmm >= 1130 && $scope.HHmm < 1200){
    $scope.time = 3;
    $scope.hours = '1130';
  }
  else if($scope.HHmm >= 1200 && $scope.HHmm < 1230){
    $scope.time = 4;
    $scope.hours = '1200';
  }

I saw in your js where they are separated by '.', how would it work for my case, any help will be greatly appreciated. Thanks!

zachary545 avatar Aug 05 '15 03:08 zachary545