我希望在当前时间等于来自JSON文件的时间时隐藏div。但我无法找到正确的方法。您可以使用此转换器来播放数据:http://www.epochconverter.com/
我的代码:
function Ctrl($scope, $timeout) {
$scope.events = [ {
"start_date" : "1288323623006",
"team1" : "FC Dynamo Kiev",
"team2" : "FC Shahtar Donetsk",
"tournaments" : [ {
"tournament_id" : "1"
} ]
}, {
"start_date" : "1416844143000",
"team1" : "FC Dynamo Kiev123",
"team2" : "FC Shahtar Donetsk",
"tournaments" : [ {
"tournament_id" : "1"
} ]
} ];
//Real time clock
$scope.clock = "loading clock..."; // initialise the time variable
$scope.tickInterval = 1000; //ms
var tick = function() {
$scope.clock = Date.now() // get the current time
$timeout(tick, $scope.tickInterval); // reset the timer
};
// Start the timer
$timeout(tick, $scope.tickInterval);
$scope.$watch('clock', function (newVal) {
$scope.clock = newVal;
console.log(newVal);
});
}

</style> <!-- Ugly Hack due to jsFiddle issue: http://goo.gl/BUfGZ -->
<link rel="stylesheet" href="http://twitter.github.com/bootstrap/assets/css/bootstrap.css">
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.0.2/angular.min.js"></script>
<style>
&#13;
<div ng-app>
<div ng-controller="Ctrl">
<div ng-repeat="event in events" ng-hide="event.start_date == clock">
<h2>{{event.team1}} vs {{event.team2}}</h2>
<p>Starts in: {{event.start_date | date: 'shortTime'}}; Current time: {{clock | date: 'shortTime'}}</p>
</div>
</div>
</div>
&#13;
答案 0 :(得分:1)
看作为==将寻找数字相等,时间可能已经过去了,你的时钟永远不会= =到日期。
尝试时间已过,而不是与&lt;时间相等。或&gt;
<div ng-repeat="event in events" ng-hide="event.start_date < clock">