首页 > 解决方案 > 未捕获的错误:模块“...”导入的意外值“...”。请添加@NgModule 注释

问题描述

我正在尝试将自己的自定义模块导入应用程序模块,但我不断收到此错误。

"Uncaught Error: Unexpected value 'ActionsService' imported by the module 'ReduxStoreModule'. Please add a @NgModule annotation."

它要我添加一个@NgModule 注释,但我的两个模块中都有@NgModule。我不知道我做错了什么。请帮忙。


app.module.ts

import { BrowserModule } from '@angular/platform-browser'
import { NgModule } from '@angular/core'
import { AppComponent } from './app.component'
import { ReduxStoreModule } from './Redux-Store/redux-store.module'

@NgModule( {
    declarations: [ AppComponent ],
    imports: [
        BrowserModule
        ,ReduxStoreModule
    ],
    providers: [],
    bootstrap: [ AppComponent ]
} )
export class AppModule { }

redux-store.module.ts

import { CommonModule } from '@angular/common'
import { NgReduxModule } from '@angular-redux/store'
import { NgModule } from '@angular/core'
import { ActionsService } from './actions'

const ImportsExports = [
    ActionsService
    ,NgReduxModule
]

@NgModule( {
    imports: ImportsExports
    ,exports: ImportsExports
} )
export class ReduxStoreModule { }

标签: angular

解决方案


服务应该在提供者下而不是在模块下,ActionsService从模块中删除并将其添加到提供者下,

const ImportsExports = [
  NgReduxModule
]

推荐阅读