Skip to content

Commit

Permalink
resolving moment value in Reactive forms
Browse files Browse the repository at this point in the history
  • Loading branch information
vlio20 committed Mar 12, 2018
1 parent ab650e0 commit 6055041
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/app/date-picker/date-picker.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -409,9 +409,10 @@ export class DatePickerComponent implements OnChanges,
this.cd.markForCheck();
}

onViewDateChange(value: string) {
if (this.dayPickerService.isValidInputDateValue(value, this.componentConfig)) {
this.selected = this.dayPickerService.convertInputValueToMomentArray(value, this.componentConfig);
onViewDateChange(value: CalendarValue) {
const strVal = value ? this.utilsService.convertToString(value, this.componentConfig.format) : '';
if (this.dayPickerService.isValidInputDateValue(strVal, this.componentConfig)) {
this.selected = this.dayPickerService.convertInputValueToMomentArray(strVal, this.componentConfig);
this.currentDateView = this.selected.length
? this.utilsService.getDefaultDisplayDate(
null,
Expand All @@ -422,8 +423,8 @@ export class DatePickerComponent implements OnChanges,
: this.currentDateView;
} else {
this._selected = this.utilsService
.getValidMomentArray(value, this.componentConfig.format);
this.onChangeCallback(this.processOnChangeCallback(value), true);
.getValidMomentArray(strVal, this.componentConfig.format);
this.onChangeCallback(this.processOnChangeCallback(strVal), true);
}
}

Expand Down
1 change: 1 addition & 0 deletions src/app/date-picker/date-picker.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {TimeSelectService} from '../time-select/time-select.service';
import {DayTimeCalendarService} from '../day-time-calendar/day-time-calendar.service';
import {ITimeSelectConfig} from '../time-select/time-select-config.model';
import {CalendarMode} from '../common/types/calendar-mode';
import {CalendarValue} from '../common/types/calendar-value';
const moment = momentNs;

@Injectable()
Expand Down

0 comments on commit 6055041

Please sign in to comment.