Getting errror - NullInjectorError: No provider for NgRedux! when integrating redux implementation
Getting errror - NullInjectorError: No provider for NgRedux! when integrating redux implementation
我正在修改现有的项目来实现 redux 实现。修改了代码,编译时发现如下错误。根据我参考的学习material,ngRedux不需要添加到providers中。将其添加到提供程序后,仍然出现错误。
**AppModule.ts**
//Activation of store.
import {NgRedux , NgReduxModule} from '@angular-redux/store';
import {IAppState,INITIAL_STATE,rootReducer} from '../store';
//Other Imports here
@NgModule({
declarations: [
AppComponent,
ViewallComponent,
WorkoutComponent,
CategoryComponent,
TrackComponent,
TestComponent,
CategoryPipe,
ActiveworkoutComponent,
WorkoutPipe,
],
imports: [
BrowserModule,
AppRoutingModule,
FormsModule,
ReactiveFormsModule,
HttpModule,
FusionChartsModule.forRoot(FusionCharts, Charts, FintTheme)
],
providers: [
WorkoutService,
CategoryService,
ActiveworkoutService
],
bootstrap: [AppComponent]
})
export class AppModule {
constructor (ngRedux: NgRedux<IAppState>) {
ngRedux.configureStore(rootReducer, INITIAL_STATE);
}
}
已对组件进行了适当的更改,并制作了存储文件。
错误:
Error: StaticInjectorError(AppModule)[AppModule -> NgRedux]:
StaticInjectorError(Platform: core)[AppModule -> NgRedux]:
NullInjectorError: No provider for NgRedux!
Stack trace:
./node_modules/@angular/core/fesm5/core.js/NullInjector.prototype.get@http://localhost:4200/vendor.js:33896:19
resolveToken@http://localhost:4200/vendor.js:34133:17
tryResolveToken@http://localhost:4200/vendor.js:34077:16
./node_modules/@angular/core/fesm5/core.js/StaticInjector.prototype.get@http://localhost:4200/vendor.js:33974:20
resolveToken@http://localhost:4200/vendor.js:34133:17
tryResolveToken@http://localhost:4200/vendor.js:34077:16`enter code here`
您需要在导入 module.ts
下添加 NgReduxModule
imports: [
NgReduxModule
]
我正在修改现有的项目来实现 redux 实现。修改了代码,编译时发现如下错误。根据我参考的学习material,ngRedux不需要添加到providers中。将其添加到提供程序后,仍然出现错误。
**AppModule.ts**
//Activation of store.
import {NgRedux , NgReduxModule} from '@angular-redux/store';
import {IAppState,INITIAL_STATE,rootReducer} from '../store';
//Other Imports here
@NgModule({
declarations: [
AppComponent,
ViewallComponent,
WorkoutComponent,
CategoryComponent,
TrackComponent,
TestComponent,
CategoryPipe,
ActiveworkoutComponent,
WorkoutPipe,
],
imports: [
BrowserModule,
AppRoutingModule,
FormsModule,
ReactiveFormsModule,
HttpModule,
FusionChartsModule.forRoot(FusionCharts, Charts, FintTheme)
],
providers: [
WorkoutService,
CategoryService,
ActiveworkoutService
],
bootstrap: [AppComponent]
})
export class AppModule {
constructor (ngRedux: NgRedux<IAppState>) {
ngRedux.configureStore(rootReducer, INITIAL_STATE);
}
}
已对组件进行了适当的更改,并制作了存储文件。
错误:
Error: StaticInjectorError(AppModule)[AppModule -> NgRedux]:
StaticInjectorError(Platform: core)[AppModule -> NgRedux]:
NullInjectorError: No provider for NgRedux!
Stack trace:
./node_modules/@angular/core/fesm5/core.js/NullInjector.prototype.get@http://localhost:4200/vendor.js:33896:19
resolveToken@http://localhost:4200/vendor.js:34133:17
tryResolveToken@http://localhost:4200/vendor.js:34077:16
./node_modules/@angular/core/fesm5/core.js/StaticInjector.prototype.get@http://localhost:4200/vendor.js:33974:20
resolveToken@http://localhost:4200/vendor.js:34133:17
tryResolveToken@http://localhost:4200/vendor.js:34077:16`enter code here`
您需要在导入 module.ts
下添加NgReduxModule
imports: [
NgReduxModule
]