11/**
2- * angular-timer - v1.2.0 - 2014-12-15 6:34 PM
2+ * angular-timer - v1.2.1 - 2015-02-25 4:19 PM
33 * https://github.com/siddii/angular-timer
44 *
5- * Copyright (c) 2014 Siddique Hameed
5+ * Copyright (c) 2015 Siddique Hameed
66 * Licensed MIT <https://github.com/siddii/angular-timer/blob/master/LICENSE.txt>
77 */
88var timerModule = angular . module ( 'timer' , [ ] )
@@ -19,7 +19,7 @@ var timerModule = angular.module('timer', [])
1919 autoStart : '&autoStart' ,
2020 maxTimeUnit : '='
2121 } ,
22- controller : [ '$scope' , '$element' , '$attrs' , '$timeout' , function ( $scope , $element , $attrs , $timeout ) {
22+ controller : [ '$scope' , '$element' , '$attrs' , '$timeout' , '$interpolate' , function ( $scope , $element , $attrs , $timeout , $interpolate ) {
2323
2424 // Checking for trim function since IE8 doesn't have it
2525 // If not a function, create tirm with RegEx to mimic native trim
@@ -35,7 +35,7 @@ var timerModule = angular.module('timer', [])
3535 $scope . autoStart = $attrs . autoStart || $attrs . autostart ;
3636
3737 if ( $element . html ( ) . trim ( ) . length === 0 ) {
38- $element . append ( $compile ( '<span>{{ millis}} </span>' ) ( $scope ) ) ;
38+ $element . append ( $compile ( '<span>' + $interpolate . startSymbol ( ) + ' millis' + $interpolate . endSymbol ( ) + ' </span>') ( $scope ) ) ;
3939 } else {
4040 $element . append ( $compile ( $element . contents ( ) ) ( $scope ) ) ;
4141 }
@@ -76,6 +76,12 @@ var timerModule = angular.module('timer', [])
7676 }
7777 }
7878
79+ $scope . $watch ( 'startTimeAttr' , function ( newValue , oldValue ) {
80+ if ( newValue !== oldValue && $scope . isRunning ) {
81+ $scope . start ( ) ;
82+ }
83+ } ) ;
84+
7985 $scope . start = $element [ 0 ] . start = function ( ) {
8086 $scope . startTime = $scope . startTimeAttr ? new Date ( $scope . startTimeAttr ) : new Date ( ) ;
8187 $scope . endTime = $scope . endTimeAttr ? new Date ( $scope . endTimeAttr ) : null ;
0 commit comments