保持获取NullInjectorError:没有提供Injector!当尝试与商店合作时

问题描述 投票:0回答:1

我正在创建一个使用商店的Web应用程序。我正在学习教程:https://coursetro.com/posts/code/151/Angular-Ngrx-Store-Tutorial---Learn-Angular-State-Management。问题是我一直遇到以下问题:

main.ts:13 NullInjectorError: StaticInjectorError(AppModule)[InjectionToken @ngrx/store Initial Reducers -> Injector]:
  StaticInjectorError(Platform: core)[InjectionToken @ngrx/store Initial Reducers -> Injector]:
    NullInjectorError: No provider for Injector!

我相信这与StoreModule.forRoot({}) ...有关>

这是我的AppModule:

import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { AppRoutingModule } from './app-routing.module';
import { AppComponent } from './app.component';
import { HomeComponent } from './components/Home/home/home.component';
import { ContactComponent } from './components/Contact/contact/contact.component';
import { StatisticsComponent } from './components/Statistics/statistics/statistics.component';
import { TrainComponent } from './components/Train/train/train.component';
import { NavBarComponent } from './components/Navigation/nav-bar/nav-bar.component';
import { WidgetComponent } from './components/Home/home/Gesture Widget/widget/widget.component';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { MatCardModule } from '@angular/material';
import { MatChipsModule } from '@angular/material';
import { CriteriaEditorComponent } from './components/Home/home/criteria-editor/criteria-editor.component';
import { FormsModule } from '@angular/forms';
import { MatFormFieldModule } from '@angular/material';
import { MatDialogModule } from '@angular/material';
import { MatInputModule } from '@angular/material';
import { DragAndDropComponent } from './components/Home/home/Drag And Drop/drag-and-drop/drag-and-drop.component';
import { DragDropModule } from '@angular/cdk/drag-drop';
import { MatExpansionModule } from '@angular/material';
import { MatButtonModule } from '@angular/material';
import { StoreModule } from '@ngrx/store';
import { reducer } from './reducers/conversion-table.reducer';

@NgModule({
    declarations: [
        AppComponent,
        HomeComponent,
        ContactComponent,
        StatisticsComponent,
        TrainComponent,
        NavBarComponent,
        WidgetComponent,
        CriteriaEditorComponent,
        DragAndDropComponent
    ],
    imports: [
        BrowserModule,
        StoreModule.forRoot({
            table: reducer
        }),
        MatButtonModule,
        MatExpansionModule,
        AppRoutingModule,
        BrowserAnimationsModule,
        MatCardModule,
        MatChipsModule,
        FormsModule,
        MatFormFieldModule,
        MatDialogModule,
        MatInputModule,
        DragDropModule
    ],
    providers: [],
    bootstrap: [AppComponent],
    entryComponents: [CriteriaEditorComponent]
})
export class AppModule {}

我正在创建一个使用商店的Web应用程序。我正在关注该教程:https://coursetro.com/posts/code/151/Angular-Ngrx-Store-Tutorial---Learn-Angular-State-Management。问题是我保留...

angular store ngrx-store
1个回答
0
投票

检查此官员link

© www.soinside.com 2019 - 2024. All rights reserved.