Angular Routing: Difference between revisions

From bibbleWiki
Jump to navigation Jump to search
Line 5: Line 5:
*Identifying where to place the route templates
*Identifying where to place the route templates
==Configuring the routes==
==Configuring the routes==
We define a path, a component and optionally a guards which provides permissions
<syntaxhighlight lang="ts">
<syntaxhighlight lang="ts">
     RouterModule.forChild([
     RouterModule.forChild([

Revision as of 13:24, 7 September 2020

Introduction

Setting up Routing requires three steps

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

Configuring the routes

We define a path, a component and optionally a guards which provides permissions

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

Activating the routes

Identifying where to place the route templates