Creating A Routing Module

Angular Routing Module

Router Module Boilerplate Explained

You do not have to memorize this code, just where to find it and why we use it.

Create an app-routing.module.ts file, within your src/app directory

app-routing.module.ts
import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';

Line 1 & 2: We need to import the NgModule, Routes and RouterModule classes from angular.

If your app compiles and serves move on to the next step.

Troubleshooting

Any errors here will be a typo for file path double check that first.

Last updated