Just like Forms, Angular doesn't generate routing by default in the CLI scaffold. This is because you might not need it in the project you're working on. To get routing working, you need to import it in the module that needs to make use of it:

import { RouterModule }   from '@angular/router';

The module exposes a static forRoot method, which is passed in an array of routes. Doing so registers and configures those routes for the module importing RouterModule. Start with creating a routes.ts file in the app folder:

import { Routes } from '@angular/router';export const routes: Routes = [  {    path: '',    component: HomeComponent  },  {    path: 'about',    component: AboutComponent  },  {    path: 'contact',    component: ContactComponent  }];

The signature ...

Get TypeScript 2.x for Angular Developers now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.