Skip to content

Commit ec8a4b2

Browse files
committed
Fix angular-ui#1114 | timepicker should not fill current time when model is null
1 parent 7b7cdf8 commit ec8a4b2

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

src/timepicker/timepicker.js

+11-5
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ angular.module('ui.bootstrap.timepicker', [])
8888
}
8989

9090
function pad( value ) {
91-
return ( angular.isDefined(value) && value.toString().length < 2 ) ? '0' + value : value;
91+
return ( angular.isObject(value) && value.toString().length < 2 ) ? '0' + value : value;
9292
}
9393

9494
// Respond on mousewheel spin
@@ -206,10 +206,16 @@ angular.module('ui.bootstrap.timepicker', [])
206206
if ( $scope.showMeridian ) {
207207
hours = ( hours === 0 || hours === 12 ) ? 12 : hours % 12; // Convert 24 to 12 hour system
208208
}
209-
210-
$scope.hours = keyboardChange === 'h' ? hours : pad(hours);
211-
$scope.minutes = keyboardChange === 'm' ? minutes : pad(minutes);
212-
$scope.meridian = selected.getHours() < 12 ? meridians[0] : meridians[1];
209+
210+
if (ngModelCtrl.$modelValue) {
211+
$scope.hours = keyboardChange === 'h' ? hours : pad(hours);
212+
$scope.minutes = keyboardChange === 'm' ? minutes : pad(minutes);
213+
$scope.meridian = selected.getHours() < 12 ? meridians[0] : meridians[1];
214+
} else {
215+
$scope.hours = null;
216+
$scope.minutes = null;
217+
$scope.meridian = null;
218+
}
213219
}
214220

215221
function addMinutes( minutes ) {

0 commit comments

Comments
 (0)