I have the following folder structure in my Angular 14 project ...
src
app
my-module
my-module.module.ts
services
my-object.service.ts
In my my-module.module.ts, I have defined
@NgModule({
declarations: [
MyObjectsComponent
],
imports: [
...
StoreModule.forRoot(reducers, {
metaReducers: [],
runtimeChecks: {
strictActionImmutability: true,
strictStateImmutability: true,
},
}),
EffectsModule.forRoot([]),
EntityDataModule.forRoot(entityConfig),
StoreRouterConnectingModule.forRoot()
],
exports: [
MyObjectsComponent
],
providers: [{ provide: DefaultDataServiceConfig, useValue: defaultDataServiceConfig }]
})
export class MyModule { }
And I have defined my my-object.service.ts like so ...
@Injectable({
providedIn: MyModule
})
export class MyObjectService extends EntityCollectionServiceBase<MyObject> {
...
}
The problem is, when I startup my application in which my main app component calls my MyObjectsComponent component, I get the JS error
ERROR Error: Uncaught (in promise): ReferenceError: can't access lexical declaration 'MyModule' before initialization
MyModule@http://localhost:8000/src_app_dashboard_dashboard_component_ts.js:585:76
What's the proper way to define a service for use with my module?