From 18ba2cf230b794e1e1405371d883e8c37654694b Mon Sep 17 00:00:00 2001 From: Li Shuai Date: Fri, 27 Jun 2014 12:00:15 +0800 Subject: [PATCH] Watch starttime&endtime --- app/js/timer.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/app/js/timer.js b/app/js/timer.js index ced1501..10cbf03 100644 --- a/app/js/timer.js +++ b/app/js/timer.js @@ -64,6 +64,18 @@ var timerModule = angular.module('timer', []) } } + $scope.$watch('startTimeAttr', function(newValue, oldValue) { + if (newValue !== oldValue && $scope.isRunning) { + $scope.start(); + } + }); + + $scope.$watch('endTimeAttr', function(newValue, oldValue) { + if (newValue !== oldValue && $scope.isRunning) { + $scope.start(); + } + }); + $scope.start = $element[0].start = function () { $scope.startTime = $scope.startTimeAttr ? new Date($scope.startTimeAttr) : new Date(); $scope.endTime = $scope.endTimeAttr ? new Date($scope.endTimeAttr) : null;