Angular 6 References/ Router
References

Route interface

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

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](../urlmatcher).

pathMatch#

pathMatch?: string
A string that specifies the matching strategy.

matcher#

matcher?: UrlMatcher
Defines a [custom strategy for path matching](../urlmatcher) 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`](../canactivate-interface) handlers.

canActivateChild#

canActivateChild?: any[]
An array of DI tokens used to look up [`CanActivateChild`](../canactivatechild-interface) handlers.

canDeactivate#

canDeactivate?: any[]
An array of DI tokens used to look up [`CanDeactivate`](../candeactivate-interface) handlers.

canLoad#

canLoad?: any[]
An array of DI tokens used to look up [`CanLoad`](../canload-interface) handlers.

data#

data?: Data
Additional data provided to the component via [`ActivatedRoute`](../activatedroute).

resolve#

resolve?: ResolveData
A map of DI tokens used to look up [data resolvers](../resolve-interface).
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.