【发布时间】:2021-08-08 14:52:27
【问题描述】:
所以我创建了一个组件 ExampleComponent 并在 app.module 中列出的 isnt 模块中声明它。 接下来,我想在 app.module 中列出的 模块中声明组件 ExampleComponent。我该怎么做呢?如果我简单地声明它,我会得到以下错误:组件 ExampleComponent 由多个 NgModule 声明。
abc.module.ts
import { ExampleComponent} from '../Example/Example.component';
@NgModule({
declarations: [
ExampleComponent
]
})
app.module.ts
import { NewModule} from '../new/new.component';
@NgModule({
imports: [
NewModule
declarations: [
]
})
新模块
import { ExampleComponent} from '../Example/Example.component';
@NgModule({
declarations: [
ExampleComponent
]
})
【问题讨论】:
-
如果它在其他模块中,则将其放入
imports:[...here...]
标签: angular typescript