Wednesday, July 4, 2018

Double asterisk for a wildcard in Angular 5 routing!

If you don't want to have a separate routing module for your outermost God module you may just jam that routing stuff into the outermost God module itself by first importing RouterModule like so...

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


...and then, at the imports metadata property in the module, having an item/entry as seen below. Do note the double asterisk for a wildcard catchall. Cool stuff. This is something more I learned from "ASP.NET Core 2 and Angular 5" by Valerio De Sanctis.

   { path: '', redirectTo: 'start', pathMatch: 'full' },
   { path: 'start', component: DefaultComponent },
   { path: '**', redirectTo: 'start' }

No comments:

Post a Comment