小编new*_*ser的帖子

该组件由多个 NgModule 声明

所以,我创建了一个组件ExampleComponent和模块,在宣布它的心不是在app.module上市。接下来,我想声明组件ExampleComponent一个模块中在app.module列出。我该怎么做呢?如果我简单地声明它,那么我会收到以下错误:组件ExampleComponent是由多个NgModule声明的。

abc.module.ts

import { ExampleComponent} from '../Example/Example.component';
@NgModule({
  declarations: [
    ExampleComponent
  ]
})
Run Code Online (Sandbox Code Playgroud)

app.module.ts

import { NewModule} from '../new/new.component';
@NgModule({
  imports: [
    NewModule
  declarations: [
    
  ]
})
Run Code Online (Sandbox Code Playgroud)

新模块

import { ExampleComponent} from '../Example/Example.component';
    @NgModule({
      declarations: [
        ExampleComponent
      ]
    })
Run Code Online (Sandbox Code Playgroud)

typescript angular

15
推荐指数
2
解决办法
2万
查看次数

标签 统计

angular ×1

typescript ×1