Route interface

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

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#

A string that uses the route matcher DSL.

path?: string

pathMatch#

A string that specifies the matching strategy.

pathMatch?: string

matcher#

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

matcher?: UrlMatcher

component#

A component type.

component?: Type<any>

redirectTo#

The url fragment which will replace the current matched segment.

redirectTo?: string
Tutorials

outlet#

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

outlet?: string
Tutorials

canActivate#

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

canActivate?: any[]

canActivateChild#

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

canActivateChild?: any[]

canDeactivate#

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

canDeactivate?: any[]

canLoad#

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

canLoad?: any[]

data#

Additional data provided to the component via ActivatedRoute.

data?: Data

resolve#

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

resolve?: ResolveData
Tutorials

children#

An array of child route definitions.

children?: Routes

loadChildren#

A reference to lazy loaded child routes.

loadChildren?: LoadChildren
Tutorials

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.

runGuardsAndResolvers?: RunGuardsAndResolvers