-
Notifications
You must be signed in to change notification settings - Fork 168
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Problem with timePicker not updating the model correctly when just using the timePicker on its own
- Loading branch information
Showing
5 changed files
with
41 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{ | ||
"name": "bootstrap-ui-datetime-picker", | ||
"version": "1.0.7", | ||
"version": "1.0.8", | ||
"homepage": "https://github.com/Gillardo/bootstrap-ui-datetime-picker", | ||
"authors": [ | ||
"Gillardo <[email protected]>" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,8 +24,8 @@ | |
scope.showButtonBar = angular.isDefined(attrs.showButtonBar) ? scope.$parent.$eval(attrs.showButtonBar) : datepickerPopupConfig.showButtonBar; | ||
|
||
// determine which pickers should be available. Defaults to date and time | ||
scope.enableDate = !(scope.enableDate == false); | ||
scope.enableTime = !(scope.enableTime == false); | ||
scope.enableDate = scope.enableDate === false; | ||
scope.enableTime = scope.enableTime === false; | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
Gillardo
via email
Author
Owner
|
||
|
||
// default picker view | ||
scope.showPicker = scope.enableDate ? 'date' : 'time'; | ||
|
@@ -50,10 +50,10 @@ | |
// popup element used to display calendar | ||
var popupEl = angular.element('' + | ||
'<div datetime-picker-popup>' + | ||
'<div ng-if="enableDate" collapse="!(showPicker == \'date\')" datepicker></div>' + | ||
'<div collapse="!(showPicker == \'time\')">' + | ||
'<div timepicker style="margin:0 auto"></div>' + | ||
'</div>' + | ||
'<div ng-if="enableDate" collapse="!(showPicker == \'date\')" datepicker></div>' + | ||
'<div collapse="!(showPicker == \'time\')">' + | ||
'<div timepicker style="margin:0 auto"></div>' + | ||
'</div>' + | ||
'</div>'); | ||
|
||
// get attributes from directive | ||
|
@@ -117,6 +117,16 @@ | |
} else if (angular.isString(viewValue)) { | ||
var date = dateParser.parse(viewValue, dateFormat) || new Date(viewValue); | ||
|
||
// has problem parsing a time only, so create a date | ||
// with the time added on the end, and a dummy formatter | ||
// and use this to see if the time is valid | ||
if (scope.enableTime && !scope.enableDate) { | ||
var timeFormat = 'EEE MMM dd yyyy ' + dateFormat; | ||
var newTime = 'Fri Mar 12 2015 ' + viewValue; | ||
|
||
date = dateParser.parse(newTime, timeFormat) || new Date(newTime); | ||
} | ||
|
||
if (isNaN(date)) { | ||
ngModel.$setValidity('date', false); | ||
return undefined; | ||
|
@@ -172,7 +182,7 @@ | |
|
||
element.bind('input change keyup', function () { | ||
scope.$apply(function () { | ||
scope.date = parseDate(ngModel.$viewValue); | ||
scope.date = ngModel.$modelValue; | ||
}); | ||
}); | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
The change to these two lines makes the datepicker never show up. It should be