|
85 | 85 | // may be confusing. |
86 | 86 | var hiddenIcons = tAttrs.mdHideIcons; |
87 | 87 | var ariaLabelValue = tAttrs.ariaLabel || tAttrs.mdPlaceholder; |
| 88 | + var ngModelOptions = tAttrs.ngModelOptions; |
88 | 89 |
|
89 | 90 | var calendarButton = (hiddenIcons === 'all' || hiddenIcons === 'calendar') ? '' : |
90 | 91 | '<md-button class="md-datepicker-button md-icon-button" type="button" ' + |
|
132 | 133 | 'md-max-date="ctrl.maxDate" ' + |
133 | 134 | 'md-date-filter="ctrl.dateFilter" ' + |
134 | 135 | 'md-month-filter="ctrl.monthFilter" ' + |
| 136 | + (ngModelOptions ? 'ng-model-options="' + ngModelOptions + '" ' : '') + |
135 | 137 | 'ng-model="ctrl.date" ng-if="ctrl.isCalendarOpen">' + |
136 | 138 | '</md-calendar>' + |
137 | 139 | '</div>' + |
|
180 | 182 | mdInputContainer.input = element; |
181 | 183 | mdInputContainer.element |
182 | 184 | .addClass(INPUT_CONTAINER_CLASS) |
183 | | - .toggleClass(HAS_CALENDAR_ICON_CLASS, attr.mdHideIcons !== 'calendar' && attr.mdHideIcons !== 'all'); |
| 185 | + .toggleClass(HAS_CALENDAR_ICON_CLASS, |
| 186 | + attr.mdHideIcons !== 'calendar' && attr.mdHideIcons !== 'all'); |
184 | 187 |
|
185 | 188 | if (!mdInputContainer.label) { |
186 | 189 | $mdAria.expect(element, 'aria-label', attr.mdPlaceholder); |
|
191 | 194 | } |
192 | 195 |
|
193 | 196 | scope.$watch(mdInputContainer.isErrorGetter || function() { |
194 | | - return ngModelCtrl.$invalid && (ngModelCtrl.$touched || (parentForm && parentForm.$submitted)); |
| 197 | + return ngModelCtrl.$invalid && (ngModelCtrl.$touched || |
| 198 | + (parentForm && parentForm.$submitted)); |
195 | 199 | }, mdInputContainer.setInvalid); |
196 | 200 | } else if (parentForm) { |
197 | 201 | // If invalid, highlights the input when the parent form is submitted. |
|
424 | 428 | }); |
425 | 429 | } |
426 | 430 |
|
427 | | - // For AngularJS 1.4 and older, where there are no lifecycle hooks but bindings are pre-assigned, |
428 | | - // manually call the $onInit hook. |
| 431 | + // For AngularJS 1.4 and older, where there are no lifecycle hooks but bindings are |
| 432 | + // pre-assigned, manually call the $onInit hook. |
429 | 433 | if (angular.version.major === 1 && angular.version.minor <= 4) { |
430 | 434 | this.$onInit(); |
431 | 435 | } |
432 | 436 | } |
433 | 437 |
|
434 | 438 | /** |
435 | 439 | * AngularJS Lifecycle hook for newer AngularJS versions. |
436 | | - * Bindings are not guaranteed to have been assigned in the controller, but they are in the $onInit hook. |
| 440 | + * Bindings are not guaranteed to have been assigned in the controller, but they are in the |
| 441 | + * $onInit hook. |
437 | 442 | */ |
438 | 443 | DatePickerCtrl.prototype.$onInit = function() { |
439 | 444 |
|
|
442 | 447 | * the user to override specific ones from the $mdDateLocale provider. |
443 | 448 | * @type {!Object} |
444 | 449 | */ |
445 | | - this.locale = this.dateLocale ? angular.extend({}, this.$mdDateLocale, this.dateLocale) : this.$mdDateLocale; |
| 450 | + this.locale = this.dateLocale ? angular.extend({}, this.$mdDateLocale, this.dateLocale) |
| 451 | + : this.$mdDateLocale; |
446 | 452 |
|
447 | 453 | this.installPropertyInterceptors(); |
448 | 454 | this.attachChangeListeners(); |
|
743 | 749 | var bodyRect = body.getBoundingClientRect(); |
744 | 750 |
|
745 | 751 | if (!this.topMargin || this.topMargin < 0) { |
746 | | - this.topMargin = (this.inputMask.parent().prop('clientHeight') - this.ngInputElement.prop('clientHeight')) / 2; |
| 752 | + this.topMargin = |
| 753 | + (this.inputMask.parent().prop('clientHeight') |
| 754 | + - this.ngInputElement.prop('clientHeight')) / 2; |
747 | 755 | } |
748 | 756 |
|
749 | 757 | // Check to see if the calendar pane would go off the screen. If so, adjust position |
|
993 | 1001 | var self = this; |
994 | 1002 | var timezone = this.$mdUtil.getModelOption(this.ngModelCtrl, 'timezone'); |
995 | 1003 |
|
996 | | - this.date = value; |
| 1004 | + if (this.dateUtil.isValidDate(value)) { |
| 1005 | + this.date = this.dateUtil.removeLocalTzAndReparseDate(value); |
| 1006 | + } else { |
| 1007 | + this.date = value; |
| 1008 | + } |
997 | 1009 | this.inputElement.value = this.locale.formatDate(value, timezone); |
998 | 1010 | this.mdInputContainer && this.mdInputContainer.setHasValue(!!value); |
999 | 1011 | this.resizeInputElement(); |
|
0 commit comments