我想比较两个日期时间对象。但alert $scope.timeDiff
显示NaN
未定义。
代码:
$scope.dbDealTime = $filter('date')(data.DealTime, 'hh:mm:ss');
$scope.TimeNow = $filter('date')(new Date(), 'hh:mm:ss');
$scope.timeDiff = $scope.dbDealTime - $scope.TimeNow;
alert($scope.timeDiff);
答案 0 :(得分:1)
$scope.timeDiff = data.DealTime - new Date();
然后对其应用过滤器
$filter('date')($scope.timeDiff, 'hh:mm:ss');
然后在警告中显示您想要的任何内容
alert($scope.timeDiff);