angular - 未捕获的错误:模块“...”导入的意外值“...”。请添加@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 { }
解决方案
服务应该在提供者下而不是在模块下,ActionsService
从模块中删除并将其添加到提供者下,
const ImportsExports = [
NgReduxModule
]
推荐阅读
- laravel - OctoberCMS - 如何从数据库中检索数据到后端图表
- dart - 关于 Dart 中的 toList()
- anylogic - 从托盘架挑选托盘时,资源池驱动程序不会继续移动
- php - 32 秒睡眠后的 PHP/Apache = 无响应
- javascript - 反应:尝试选中/取消选中复选框
- swiftui - 场景相位意外变化
- html - Flex-wrap 似乎不起作用,图像显示在列中
- mysql - SQL QUERY:想查询每个movie_type有多少观众;(其中喜剧 = 喜剧和戏剧喜剧)
- node.js - Node js es6 import and export
- c# - 替换不需要的字符时如何防止某些单词一起运行?