Agranom / ngx-material-timepicker

Material desing timepicker for Angular 6.0+
https://agranom.github.io/ngx-material-timepicker/
MIT License
342 stars 139 forks source link

TimeLocale #259

Closed skywalkerdark closed 4 years ago

skywalkerdark commented 4 years ago

ERROR NullInjectorError: R3InjectorError(AppModule)[InjectionToken TimeLocale -> InjectionToken TimeLocale -> InjectionToken TimeLocale]: NullInjectorError: No provider for InjectionToken TimeLocale!

What is TimeLocale and where can I find it?

alexander-kiriliuk commented 4 years ago

You can try import picker-module in your root application module by calling setLocale(). That should work

Coooi commented 4 years ago

Thank you @AlexanderKiriluyk , worked perfectly!

OLDIN commented 4 years ago

I got the same error in angular v9 with ivy and the setLocal method doesn't help me. installed version : 5.4.2

ERROR NullInjectorError: R3InjectorError(AppModule)[InjectionToken TimeLocale -> InjectionToken TimeLocale -> InjectionToken TimeLocale]: 
  NullInjectorError: No provider for InjectionToken TimeLocale!
OLDIN commented 4 years ago

@Agranom Is there any quick workaround?

Agranom commented 4 years ago

Not sure. I'll update to 9 angular this week and check

Agranom commented 4 years ago

Updated the repo to ng9 and checked. Working without errors. You can see it on the demo page

OLDIN commented 4 years ago

@Agranom I see a commit with update. Have you update the NPM version?

Agranom commented 4 years ago

@OLDIN Yes. Try the latest version

mahdiprog commented 4 years ago

@Agranom I have the same issue on Angular@9.1 and ngx-material-timepicker@5.5.0. but I used ngx-timepicker-field and @AlexanderKiriluyk's solution not worked for me. and the v4.0.2 is working

OLDIN commented 4 years ago

Temporary fix, but very badly

This can be fixed by explicitly specifying TIME_LOCALE in your app.module.ts:

{
    provide: TIME_LOCALE,
    useValue: ''
}

Full example with import:

import { ɵe as TIME_LOCALE } from 'ngx-material-timepicker'; // nice import :D

@NgModule({
  imports: [],
  providers: [
    {
      provide: TIME_LOCALE,
      useValue: ''
    }
  ],
  bootstrap: [AppComponent],
})
export class AppModule {}
Agranom commented 4 years ago

@mahdiprog can you provide with a code snippet how you use it, because it works well with ng9 for me

Agranom commented 4 years ago

For now it fixes by importing NgxMaterialTimepickerModule into a root module

Agranom commented 4 years ago

Seems to be fixed in v5.5.2