Route interface

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

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[]

children#

An array of child route definitions.

children?: Routes

component#

A component type.

component?: Type<any>

data#

Additional data provided to the component via ActivatedRoute.

data?: Data

loadChildren#

A reference to lazy loaded child routes.

loadChildren?: LoadChildren
Tutorials

matcher#

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

matcher?: UrlMatcher

outlet#

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

outlet?: string
Tutorials

path#

A string that uses the route matcher DSL.

path?: string

pathMatch#

A string that specifies the matching strategy.

pathMatch?: string

redirectTo#

The url fragment which will replace the current matched segment.

redirectTo?: string
Tutorials

resolve#

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

resolve?: ResolveData
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