我有一个 hello 组件,我想在其中导入 hello 组件的 html 中的标头组件,但我不能,我也找不到我的错误。
hello.html
<div class="header">
<app-header></app-header>
</div>
hello.module.ts
const appRoutes: Routes = [
{ path: 'hello', component: HelloComponent }
];
@NgModule({
declarations: [
HeaderComponent
],
imports: [
RouterModule.forChild(appRoutes)
],
exports: [
RouterModule
]
})
export class HelloModule { }
我没有在 app.module.ts 中声明头组件,因为我已经在 hello.module.ts 中声明了它
app.module.ts
@NgModule({
declarations: [
AppComponent
],
imports: [
BrowserModule,
AppRoutingModule,
HelloModule,
ProductModule,
BrowserAnimationsModule
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule { }