Assignment #16 - Adding Routing Angular is a Single PAge Application, which mean we have only one HTML page, and if the User needs to see other components we need to change out an exisiting component with the new one. When we created the Angular Project, we were asked a series of questions, including if we wanted Routing added to the project, we said Yes. (See Assignment #4) the result of this was our app.module.ts has a "placeholder" for Routing. If we had said No to the question, we could add Routing later via this command: ng generate module app-routing --flat --module=app --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 resulting app.module.ts entry is: import { NgModule } from '@angular/core'; import { BrowserModule } from '@angular/platform-browser'; import { HttpClientModule } from '@angular/common/http'; import { AppRoutingModule } from './app-routing.module'; <= this is added to our Module import { AppComponent } from './app.component'; import { MenuComponent } from './menu/menu.component'; import { WelcomeComponent } from './welcome/welcome.component'; import { MessageComponent } from './message/message.component'; import { FooterComponent } from './footer/footer.component'; import { NumberedComponent } from './numbered/numbered.component'; import { KeyedComponent } from './keyed/keyed.component'; import { DatedComponent } from './dated/dated.component'; @NgModule({ declarations: [ AppComponent, MenuComponent, WelcomeComponent, MessageComponent, FooterComponent, NumberedComponent, KeyedComponent, DatedComponent ], imports: [ BrowserModule, AppRoutingModule, <= this is also added HttpClientModule ], providers: [], bootstrap: [AppComponent] }) export class AppModule { } -------------------------------------------------------------------------- We also get an "starter" app-routing.module.ts file that looks like: import { NgModule } from '@angular/core'; import { Routes, RouterModule } from '@angular/router'; const routes: Routes = []; <= notice this is empty @NgModule({ imports: [RouterModule.forRoot(routes)], exports: [RouterModule] }) export class AppRoutingModule { } -------------------------------------------------------------------------- We want our menu links to switch components, take out the welcome, component and put in the numbered component (for example) right now our app.component.html file looks like this: