html:html
<!-- Countdown --> <div style="margin: 30px auto; width: 45px; height: 45px; border: 3px solid gray; border-radius: 30px; text-align: center; line-height: 42px; vertical-align: middle; color: blue;"> {{countdown}} </div>
JS:app
$scope.countdown = 10; var myTime = setInterval(function() { $scope.$apply(function() { $scope.countdown--; }); }, 1000); // 倒計時10-0秒,但算上0的話就是11s setTimeout(function() { clearInterval(myTime); $scope.countdown.$destroy(); }, 11000);
其實也能夠用內置服務$timeout作,可在界面的刷新方面總弄很差,還在探索中...spa