diff --git a/app/js/_timer.js b/app/js/_timer.js index 79c1a4b..e64c61c 100644 --- a/app/js/_timer.js +++ b/app/js/_timer.js @@ -91,8 +91,15 @@ var timerModule = angular.module('timer', []) } $scope.$watch('startTimeAttr', function(newValue, oldValue) { - if (newValue !== oldValue && $scope.isRunning) { + if (newValue !== oldValue) { + if ($scope.isRunning) { $scope.start(); + } else { + $scope.startTime = $scope.startTimeAttr ? moment($scope.startTimeAttr) : moment(); + $scope.endTime = $scope.endTimeAttr ? moment($scope.endTimeAttr) : null; + tick(); + $scope.clear(); + } } }); diff --git a/dist/angular-timer.js b/dist/angular-timer.js index 04d57e2..d462bc6 100644 --- a/dist/angular-timer.js +++ b/dist/angular-timer.js @@ -98,8 +98,15 @@ var timerModule = angular.module('timer', []) } $scope.$watch('startTimeAttr', function(newValue, oldValue) { - if (newValue !== oldValue && $scope.isRunning) { + if (newValue !== oldValue) { + if ($scope.isRunning) { $scope.start(); + } else { + $scope.startTime = $scope.startTimeAttr ? moment($scope.startTimeAttr) : moment(); + $scope.endTime = $scope.endTimeAttr ? moment($scope.endTimeAttr) : null; + tick(); + $scope.clear(); + } } });