I'm building a custom calendar, and I extend from NbCalendarDayCellComponent<Date>.
I need to inject other services to my customCellComponent but if I do that, I need to inject NbDateService and I receive the following error:
ERROR NullInjectorError: R3InjectorError(AppModule)[NbDateService -> NbDateService -> NbDateService]: NullInjectorError: No provider for NbDateService
I tried adding different modules and didn't work.
In your app.module.ts add:
// ...
import { NbDatepickerModule } from '@nebular/theme';
// ...
@NgModule({
//...
imports: [
NbDatepickerModule,
],
//...
})
Then on your CustomCellDayComponent it will work this:
export class CustomCellDayComponent extends NbCalendarDayCellComponent<Date>
implements OnInit, OnDestroy {
constructor(public nbDateService: NbDateService<Date>,){
super(nbDateService);
}
}
You can try to add a provider NbDateService in App.module.ts
@NgModule({
declarations: [
AppComponent
],
imports: [
BrowserModule,
AppRoutingModule,
NgxGenericTableModule,
BrowserAnimationsModule
],
providers: [
NbDateService // Add provider in your app.module
],
bootstrap: [AppComponent]
})