我正在尝试将 Angular 5 应用程序拆分为模块。工作代码是这样的(相关代码):
app.module.ts:
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { FooterComponent } from './path/to/component';
@NgModule({
declarations: [AppComponent, FooterComponent],
imports: [BrowserModule],
bootstrap: [AppComponent]
})
export class AppModule { }
app.component.html:
<app-footer></app-footer>
现在我想使用页脚将其更改为模块(只是更改):
app.module.ts:
import { FooterModule } from './path/to/module';
@NgModule({
declarations: [AppComponent, FooterModule],
imports: [BrowserModule],
bootstrap: [AppComponent]
})
export class AppModule { }
页脚.module.ts:
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { RouterModule} from '@angular/router';
import { FooterComponent } from './footer.component';
@NgModule({
declarations: [FooterComponent],
imports: [
CommonModule,
RouterModule.forChild([
{ path: 'footer', component: FooterComponent }
])
]
})
export class FooterModule { }
此代码不起作用,我不知道出了什么问题。你能帮我一个提示吗?提前致谢。