The Router documentation contains a pretty good explanation on the Angular module pattern, and how to organize the main module and feature modules in a real-world Angular application.
You’ll organize the crisis center to conform to the following
recommended pattern for Angular apps:
- Each feature area in its own folder
- Each area with its own area root component
- Each area root component with its own router outlet and child routes
- Area routes rarely (if ever) cross
The AppModule
itself is a stripped down component, the central hub for your application, if you will. It acts as a container for non-terminal feature module routes and application wide services. Like in the above linked doc:
@Component(
selector: 'my-app',
template: '''
<h1>Angular Router</h1>
<nav>
<a [routerLink]="['CrisisCenter']">Crisis Center</a>
<a [routerLink]="['Heroes']">Heroes</a>
</nav>
<router-outlet></router-outlet>
''',
styles: const ['.router-link-active {color: #039be5;}'],
directives: const [ROUTER_DIRECTIVES],
providers: const [HeroService],
)
@RouteConfig(const [
const Redirect(path: '/', redirectTo: const ['Heroes']),
const Route(
path: '/crisis-center/...',
name: 'CrisisCenter',
component: CrisisCenterComponent),
const Route(path: '/heroes', name: 'Heroes', component: HeroesComponent),
const Route(
path: '/hero/:id', name: 'HeroDetail', component: HeroDetailComponent),
const Route(path: '/**', name: 'NotFound', component: NotFoundComponent)
])
class AppComponent {}