When the project is large enough, the import code in the App.module.ts is too many, so separate.
Just write the references in the individual modules separately:
1 Import {Ngmodule} from ' @angular/core '; 2 Import {Commonmodule} from "@angular/common",//<--ngif, Ngfor and other Directives 3 import {Formsmodule} from "@angular/forms"; <--Ngmodel lives here two-way binding 4 import {heroescomponent} from './heroes.component ' 5 import {herodetailcomponent} f Rom './hero-detail.component '; 6 7 8 @NgModule ({9 imports: [ commonmodule,11 FormsModule12 ],13 declarations: [14 heroescomponent,15 HeroDetailComponent16 ]17}) Export class Heromodule {}
At the beginning of the error is because
Mainly imports: []
Can't write the following two componet
I wrote more. Sometimes it is not enough to understand the principle.
Then import it in the app.module.ts.
Angular separating app.module.ts code