Skip to content

Commit ffe15d8

Browse files
committed
Watching startTimeAttr and restarting timer if changed
1 parent d34157e commit ffe15d8

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

app/js/timer.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,12 @@ angular.module('timer', [])
6464
}
6565
}
6666

67+
$scope.$watch('startTimeAttr', function(newValue, oldValue) {
68+
if (newValue !== oldValue && $scope.isRunning) {
69+
$scope.start();
70+
}
71+
});
72+
6773
$scope.start = $element[0].start = function () {
6874
$scope.startTime = $scope.startTimeAttr ? new Date($scope.startTimeAttr) : new Date();
6975
$scope.endTime = $scope.endTimeAttr ? new Date($scope.endTimeAttr) : null;

0 commit comments

Comments
 (0)