I'm working on an Angular app where I have a material modal (entry component), I want to inject my AuthService and my ngrx store into that modal but whenever I open the modal I get those errors
core.js:4352 ERROR NullInjectorError: R3InjectorError[AuthService -> AuthService -> Store -> Store -> Store]:
NullInjectorError: No provider for Store!
ERROR TypeError: Cannot read property 'focusInitialElementWhenReady' of undefined
what should I do ?
NullInjectorError
almost always mean, that you are missing some imports in your app or component module. In your case, the Store
is missing. Best solution would be to provide the StoreModule
in the AppModule
:
@NgModule({
imports: [
// more imports
StoreModule.forRoot() <--
],
// more stuff
})
export class AppModule {}