Add the AppRoutingModule
In Angular, the best practice is to load and configure the router in a separate, top-level module that is dedicated to routing and imported by the root AppModule.
By convention, the module class name is AppRoutingModule and it belongs in the app-routing.module.ts in the src/app folder.
Use the CLI to generate it.
ng generate module app-routing --flat --module=app
Where
flat puts the file in src/app instead of its own folder.
module=app tells the CLI to register it in the imports array of the AppModule.
The generated file looks like this:
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
@NgModule({
imports: [
CommonModule
],
declarations: []
})
export class AppRoutingModule { }
Credit: Angular.io
app command-line Modules NgModule Routing