I'm using Angular with NGXS store, usually everything works fine, but i've quite strange problem with the pretty-much basic case.
State:
@State({
name: 'items',
defaults
})
class ItemsState {
constructor(private itemsService: ItemsService) {}
...
}
Module:
@NgModule([
imports: [
NgxsModule.forFeature([ ItemsState ])
]
])
ItemsModule {}
Service:
@Service({ providedIn: 'root' })
ItemsService { ... }
Error:
Uncaught TypeError: Cannot read properties of undefined (reading 'ItemsModule')
Angular version: 15.2.9 NGXS version: 3.8.1
It took some time to localize the problem, but i found that everything works fine if I'm removing the NxsModule.forFeature(...) import, or using a different state class.
In case if i'm trying to import the same feature module with ItemsState into the different module - everything works fine, I'm also able to use different state in ItemsModule, but this particular combination gives an error.
What could be the problem?