How To Get Current Time From Angular Timer
I am testing the Angular Timer and have found myself wondering about how to get the current time inside my controller in order to use it to whatever purpose I might have. For insta
Solution 1:
You can use timer-tick event here
$scope.$on('timer-tick', function (event, data) {
if ($scope.timerRunning === true && data.millis >= $scope.deadlineInMilli) {
$scope.$apply($scope.turnRed);
}
});
And you need to convert your minutes to milliseconds for comparison
$scope.startTimer = function (deadline) {
....
$scope.deadlineInMilli = +deadline * 1000 * 60; // converting to milliseconds
};
See the DEMO
Post a Comment for "How To Get Current Time From Angular Timer"