This content applies to v6 and is no longer being maintained. For v7 and later, see current documentation here.
Generating a route
The CLI supports routing in several ways:
We include the
@angular/routerNPM package when creating or initializing a project.
When you generate a module, you can use the
ng g module my-module --routingto create a separate file
my-module-routing.module.tsto store the module routes.
The file includes an empty
Routesobject that you can fill with routes to different components and/or modules.
You can use the
ng newto create a
app-routing.module.tsfile when you create or initialize a project.