Skip to content

Commit 252538f

Browse files
committed
Merge pull request siddii#71 from leamagic/master
Watching startTimeAttr and restarting timer if changed
2 parents 167c061 + ffe15d8 commit 252538f

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

app/js/timer.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,12 @@ var timerModule = angular.module('timer', [])
6969
}
7070
}
7171

72+
$scope.$watch('startTimeAttr', function(newValue, oldValue) {
73+
if (newValue !== oldValue && $scope.isRunning) {
74+
$scope.start();
75+
}
76+
});
77+
7278
$scope.start = $element[0].start = function () {
7379
$scope.startTime = $scope.startTimeAttr ? new Date($scope.startTimeAttr) : new Date();
7480
$scope.endTime = $scope.endTimeAttr ? new Date($scope.endTimeAttr) : null;

0 commit comments

Comments
 (0)