danielmoncada / date-time-picker

Angular Date Time Picker (Responsive Design)
https://daniel-projects.firebaseapp.com/owlng/date-time-picker
MIT License
141 stars 61 forks source link

Setting locale does not work #59

Closed jaco-terbraak closed 4 years ago

jaco-terbraak commented 4 years ago

Whenever i set the locale using e.g. {provide: OWL_DATE_TIME_LOCALE, useValue: 'nl'}

I end up with the runtime error as follows:


        at SafeSubscriber._next (danielmoncada-angular-datetime-picker.js:706)```
danielmoncada commented 4 years ago

@jaco-terbraak you need to also register it with Angular.

example:

import { BrowserModule } from '@angular/platform-browser';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { NgModule, LOCALE_ID } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { OwlDateTimeModule, OwlNativeDateTimeModule } from '../../projects/picker/src/public_api';
import { AppComponent } from './app.component';
import { OWL_DATE_TIME_LOCALE } from '../../projects/picker/src/public_api';
import localeNl from '@angular/common/locales/nl';
import { registerLocaleData } from '@angular/common';
registerLocaleData(localeNl);

@NgModule({
  declarations: [
    AppComponent
  ],
  imports: [
    BrowserModule, BrowserAnimationsModule, FormsModule,
    OwlDateTimeModule, OwlNativeDateTimeModule
  ],
  providers: [
    {provide: LOCALE_ID, useValue: 'nl-NL' },
   { provide: OWL_DATE_TIME_LOCALE, useValue: 'nl-NL' }
  ],
  bootstrap: [AppComponent]
})
export class AppModule { }
danielmoncada commented 4 years ago

@jaco-terbraak just checking to see if there's an update on this issue / if you have tried the above..

jaco-terbraak commented 4 years ago

@danielmoncada sorry for not responding.

I had it registered exactly in this way, but it didn't work. Maybe it's relevant to know I was using OwlMomentDateTimeModule instead of the Native variant.

I've since moved on to using ng-pick-datetime-ex, which did work without problems.

danielmoncada commented 4 years ago

@jaco-terbraak yeah that could have been it, as I've seen other issues with usage when mixing the separate adapter package with this package (which should use the internal). I'll close, thanks