Skip to content

Commit

Permalink
fix: fix initial value render in date time picker
Browse files Browse the repository at this point in the history
  • Loading branch information
sashaqred committed Apr 6, 2022
1 parent aedfbd3 commit 2759ac6
Showing 1 changed file with 18 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,10 @@ import { NB_DATE_SERVICE_OPTIONS } from './datepicker.directive';
template: '',
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class NbDateTimePickerComponent<D> extends NbBasePickerComponent<D, D, NbCalendarWithTimeComponent<D>>
implements OnInit {

export class NbDateTimePickerComponent<D>
extends NbBasePickerComponent<D, D, NbCalendarWithTimeComponent<D>>
implements OnInit
{
protected pickerClass: Type<NbCalendarWithTimeComponent<D>> = NbCalendarWithTimeComponent;

get value(): any {
Expand Down Expand Up @@ -112,19 +113,22 @@ export class NbDateTimePickerComponent<D> extends NbBasePickerComponent<D, D, Nb
return this.valueChange as EventEmitter<D>;
}

constructor(@Inject(NB_DOCUMENT) document,
positionBuilder: NbPositionBuilderService,
triggerStrategyBuilder: NbTriggerStrategyBuilderService,
overlay: NbOverlayService,
cfr: ComponentFactoryResolver,
dateService: NbDateService<D>,
@Optional() @Inject(NB_DATE_SERVICE_OPTIONS) dateServiceOptions,
protected calendarWithTimeModelService: NbCalendarTimeModelService<D>) {
constructor(
@Inject(NB_DOCUMENT) document,
positionBuilder: NbPositionBuilderService,
triggerStrategyBuilder: NbTriggerStrategyBuilderService,
overlay: NbOverlayService,
cfr: ComponentFactoryResolver,
dateService: NbDateService<D>,
@Optional() @Inject(NB_DATE_SERVICE_OPTIONS) dateServiceOptions,
protected calendarWithTimeModelService: NbCalendarTimeModelService<D>,
) {
super(document, positionBuilder, triggerStrategyBuilder, overlay, cfr, dateService, dateServiceOptions);
}

ngOnInit() {
this.format = this.format || this.buildTimeFormat();
this.init$.next();
}

protected patchWithInputs() {
Expand All @@ -140,8 +144,9 @@ export class NbDateTimePickerComponent<D> extends NbBasePickerComponent<D, D, Nb
if (this.twelveHoursFormat) {
this.picker.timeFormat = this.dateService.getTwelveHoursFormat();
} else {
this.picker.timeFormat = this.withSeconds ? this.dateService.getTwentyFourHoursFormatWithSeconds() :
this.dateService.getTwentyFourHoursFormat();
this.picker.timeFormat = this.withSeconds
? this.dateService.getTwentyFourHoursFormatWithSeconds()
: this.dateService.getTwentyFourHoursFormat();
}
super.patchWithInputs();

Expand All @@ -168,4 +173,3 @@ export class NbDateTimePickerComponent<D> extends NbBasePickerComponent<D, D, Nb
}
}
}

0 comments on commit 2759ac6

Please sign in to comment.