Angular Routing

From bibbleWiki
Jump to navigation Jump to search

Introduction

Setting up Routing requires three steps

  • Configuring the routes
  • Activating the routes
  • Identifying where to place the route templates

Configuring the routes

<syntaxhighlighting lang="ts">

   RouterModule.forChild([
     { path: 'products', component: ProductListComponent },
     { path: 'products/:id', component: ProductDetailComponent },
     {
       path: 'products/:id/edit',
       canDeactivate: [ProductEditGuard],
       component: ProductEditComponent
     }
   ])

</syntaxhighlighting>

Activating the routes

Identifying where to place the route templates