web-dave / angular-starter-v2

6 stars 3 forks source link

Start Routing #5

Open web-dave opened 7 years ago

web-dave commented 7 years ago
web-dave commented 7 years ago

my-nav.component.html

    <li><a [routerLink]="['books']">Books</a></li>
    <li><a [routerLink]="['about']">About</a></li>
web-dave commented 7 years ago

app-routing.module.ts

const routes: Routes = [
  {
    path: 'books',
    component: BooksComponent
  },
  {
    path: 'about',
    component: AboutComponent
  },
  {
    path: '',
    redirectTo: '/books',
    pathMatch: 'full' <-- !!
  },
  {
    path: '**', <-- Fallback allways the last route!
    redirectTo: '/about'
  }
];