Closed Kyoss79 closed 4 years ago
I fixed it with the following code ... but I'd rather not:
this.renderer.setProperty(this.elmRef.nativeElement, 'value', this._value ? this.dateTimeAdapter.format(this._value, this.dtPicker && this.dtPicker.formatString) : '');
@Kyoss79 thanks for the support.
Let me look into this, and get back to you. I'm aiming for a fix and package update this weekend.
@Kyoss79 is there any way you can provide a StackBlitz to reproduce the issue? I'm having trouble getting that error.
Also are try using the OWL_DATE_TIME_LOCALE instead of the Angular LOCALE_ID.
providers: [
{ provide: OWL_DATE_TIME_LOCALE, useValue: 'de' }
],
Hello daniel! Thanks for your fast feedback. I tried replicating the issue, but could not. Our app is very complicated. However I have to provide the LOCALE_ID in angular, or otherwise the datePicker does not format the dates correctly.
I was however able to fix the issue on our side of the application.
We had intialized the formValue twice it seems as in
[formControlName]="myFormCtrl" [value]="myFormCtrl.value
If you are interested in the stackblitz (angular9, german LOCALE) here it is: https://stackblitz.com/edit/angular-82y6km
Keep up the good work!
@Kyoss79 thanks for the update and clarification with the example. Glad you got it working on your side. I'm going to go ahead and close this.
Cheers! 👍
I fixed it with the following code ... but I'd rather not:
this.renderer.setProperty(this.elmRef.nativeElement, 'value', this._value ? this.dateTimeAdapter.format(this._value, this.dtPicker && this.dtPicker.formatString) : '');
@danielmoncada Hello Daniel, thank you for porting this library. I have to say I have the same problem and I fixed with these codes. Please focus on this problem because I don't want to modify the source code in my local. Thank you again.
Hey Daniel, first of thanks for porting this to Angular9! Big thumbs up. Almost Everything seems to be working fine, however when I load up a form with an already existing date-value, I get the following error:
TypeError: Cannot read property 'formatString' of undefined at OwlDateTimeInputDirective.formatNativeInputValue (danielmoncada-angular-datetime-picker.js:3371) at OwlDateTimeInputDirective.set value [as value] (danielmoncada-angular-datetime-picker.js:3216)
We just imported the
However we have the default LOCALE_ID of 'de' set in angular.
Maybe you can help.