AngularJS:对小时和分钟数组进行排序

AngularJS: Sort an array of hours and minutes

我在 angular 应用程序中使用 nvd3 图表。我得到以下格式的标签

["14:49", "14:58", "14:57", "14:56", "14:55", "14:54", "14:53", "14:52", "14:51"]

我必须根据 time.This 对它们进行排序

var hourMin = new Date($scope.items[i].timestamp);
$scope.labels[i] = hourMin.getHours() + ":" + hourMin.getMinutes();

HTML :

<canvas id="line" class="chart chart-line" chart-data="data"
                 chart-labels="labels" chart-legend="true" chart-series="series"
                 chart-click="onClick" >
  </canvas>

我已经尝试 orderBy 但它不起作用。帮帮我。

用这个......

<script>
  angular.module('app', [])
  .controller('test', ['$scope', function($scope){
    var test =  ["14:49", "14:58", "14:57", "14:56", "14:55", "14:54", "14:53", "14:52", "14:51"];
    test.sort(function (a, b) {
      return new Date('1970/01/01 ' + a) - new Date('1970/01/01 ' + b);
    });
    console.log(test);
  }])
</script>