1
1
/**
2
- * angular-timer - v1.2.0 - 2014-12-15 6:34 PM
2
+ * angular-timer - v1.2.1 - 2015-02-25 4:19 PM
3
3
* https://github.com/siddii/angular-timer
4
4
*
5
- * Copyright (c) 2014 Siddique Hameed
5
+ * Copyright (c) 2015 Siddique Hameed
6
6
* Licensed MIT <https://github.com/siddii/angular-timer/blob/master/LICENSE.txt>
7
7
*/
8
8
var timerModule = angular . module ( 'timer' , [ ] )
@@ -19,7 +19,7 @@ var timerModule = angular.module('timer', [])
19
19
autoStart : '&autoStart' ,
20
20
maxTimeUnit : '='
21
21
} ,
22
- controller : [ '$scope' , '$element' , '$attrs' , '$timeout' , function ( $scope , $element , $attrs , $timeout ) {
22
+ controller : [ '$scope' , '$element' , '$attrs' , '$timeout' , '$interpolate' , function ( $scope , $element , $attrs , $timeout , $interpolate ) {
23
23
24
24
// Checking for trim function since IE8 doesn't have it
25
25
// If not a function, create tirm with RegEx to mimic native trim
@@ -35,7 +35,7 @@ var timerModule = angular.module('timer', [])
35
35
$scope . autoStart = $attrs . autoStart || $attrs . autostart ;
36
36
37
37
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 ) ) ;
39
39
} else {
40
40
$element . append ( $compile ( $element . contents ( ) ) ( $scope ) ) ;
41
41
}
@@ -76,6 +76,12 @@ var timerModule = angular.module('timer', [])
76
76
}
77
77
}
78
78
79
+ $scope . $watch ( 'startTimeAttr' , function ( newValue , oldValue ) {
80
+ if ( newValue !== oldValue && $scope . isRunning ) {
81
+ $scope . start ( ) ;
82
+ }
83
+ } ) ;
84
+
79
85
$scope . start = $element [ 0 ] . start = function ( ) {
80
86
$scope . startTime = $scope . startTimeAttr ? new Date ( $scope . startTimeAttr ) : new Date ( ) ;
81
87
$scope . endTime = $scope . endTimeAttr ? new Date ( $scope . endTimeAttr ) : null ;
0 commit comments