Route interface

This is the documentation for Angular 6.
You can switch to the latest version Angular 9.

Routes is an array of route configurations. Pass it to the RouterModule.forRoot or forChild method in the module imports to configure the router.

Example

...
RouterModule.forRoot([
  {
    path: 'team/:id',
    component: Team,
    children: [{
      path: 'user/:name',
      component: User,
    }],
  },
]),

Options

path#

path?: string

A string that uses the route matcher DSL.

pathMatch#

pathMatch?: string

A string that specifies the matching strategy.

matcher#

matcher?: UrlMatcher

Defines a custom strategy for path matching and supersedes path and pathMatch.

component#

component?: Type<any>

A component type.

redirectTo#

redirectTo?: string

The url fragment which will replace the current matched segment.

Links & Tutorials

outlet#

outlet?: string

The name of the outlet the component should be placed into.

Links & Tutorials

canActivate#

canActivate?: any[]

An array of DI tokens used to look up CanActivate handlers.

canActivateChild#

canActivateChild?: any[]

An array of DI tokens used to look up CanActivateChild handlers.

canDeactivate#

canDeactivate?: any[]

An array of DI tokens used to look up CanDeactivate handlers.

canLoad#

canLoad?: any[]

An array of DI tokens used to look up CanLoad handlers.

data#

data?: Data

Additional data provided to the component via ActivatedRoute.

resolve#

resolve?: ResolveData

A map of DI tokens used to look up data resolvers.

Links & Tutorials

children#

children?: Routes

An array of child route definitions.

loadChildren#

loadChildren?: LoadChildren

A reference to lazy loaded child routes.

Links & Tutorials

runGuardsAndResolvers#

runGuardsAndResolvers?: RunGuardsAndResolvers

Defines when guards and resolvers will be run. By default they run only when the matrix parameters of the route change. When set to paramsOrQueryParamsChange they will also run when query params change. And when set to always, they will run every time.