bug fixed in datePicker

This commit is contained in:
dherrero 2017-10-11 14:21:32 +02:00
parent e52b31ceb3
commit 80bbd9e5d4
2 changed files with 4 additions and 3 deletions

View File

@ -37,7 +37,8 @@ class DatePicker extends Component {
set model(value) {
this._model = value;
if (value && !this.modelView) {
let format = this._formatFlat2Angular(this.iniOptions.dateFormat || 'Y-m-d');
let initialDateFormat = (this.iniOptions && this.iniOptions.dateFormat) ? this.iniOptions.dateFormat : 'Y-m-d';
let format = this._formatFlat2Angular(initialDateFormat);
this.modelView = this.$filter('date')(value, format);
}
}
@ -83,7 +84,7 @@ class DatePicker extends Component {
let model;
if (!value) {
model = undefined;
} else if (!this.iniOptions.dateFormat || (this.iniOptions.dateFormat && this.iniOptions.dateFormat.startsWith('Y-m-d'))) {
} else if (!this.iniOptions || (this.iniOptions.dateFormat && this.iniOptions.dateFormat.startsWith('Y-m-d'))) {
model = value;
} else {
let formats = this.iniOptions.dateFormat.split(/[ZT.,/ :-]/);

View File

@ -11,7 +11,7 @@
<vn-vertical pad-large>
<vn-title>Create Route</vn-title>
<vn-horizontal>
<vn-date-picker vn-one label="Date" field="$ctrl.delivery.date"></vn-date-picker>
<vn-date-picker vn-one label="Date" model="$ctrl.delivery.date"></vn-date-picker>
<vn-textfield vn-one label="Agency" field="$ctrl.delivery.agency"></vn-textfield>
</vn-horizontal>
<vn-horizontal>