Router • Angular
An event stream for routing events.
The current state of routing in this NgModule.
@deprecated
Configure using providers instead:
{provide: RouteReuseStrategy, useClass: MyStrategy}.
A strategy for re-using routes.
Sets up the location change listener. This listener detects navigations triggered from outside the Router (the browser back/forward buttons, for example) and schedules a corresponding Router navigation so that the correct events, guards, etc. are triggered.
@returnsvoid
Resets the route configuration used for navigation and generating links.
@paramconfigRoutes
The route array for the new configuration.
@returnsvoid
Usage notes
router.resetConfig([ { path: 'team/:id', component: TeamCmp, children: [ { path: 'simple', component: SimpleCmp }, { path: 'user/:name', component: UserCmp } ]}]);
Disposes of the router.
@returnsvoid
Appends URL segments to the current URL tree to create a new URL tree.
@paramcommandsreadonly any[]
An array of URL fragments with which to construct the new URL tree.
If the path is static, can be the literal URL string. For a dynamic path, pass an array of path
segments, followed by the parameters for each segment.
The fragments are applied to the current URL tree or the one provided in the relativeTo
property of the options object, if supplied.
Usage notes
// create /team/33/user/11router.createUrlTree(['/team', 33, 'user', 11]);// create /team/33;expand=true/user/11router.createUrlTree(['/team', 33, {expand: true}, 'user', 11]);// you can collapse static segments like this (this works only with the first passed-in value):router.createUrlTree(['/team/33/user', userId]);// If the first segment can contain slashes, and you do not want the router to split it,// you can do the following:router.createUrlTree([{segmentPath: '/one/two'}]);// create /team/33/(user/11//right:chat)router.createUrlTree(['/team', 33, {outlets: {primary: 'user/11', right: 'chat'}}]);// remove the right secondary noderouter.createUrlTree(['/team', 33, {outlets: {primary: 'user/11', right: null}}]);// assuming the current url is `/team/33/user/11` and the route points to `user/11`// navigate to /team/33/user/11/detailsrouter.createUrlTree(['details'], {relativeTo: route});// navigate to /team/33/user/22router.createUrlTree(['../22'], {relativeTo: route});// navigate to /team/44/user/22router.createUrlTree(['../../team/44/user/22'], {relativeTo: route});
Note that a value of null or undefined for relativeTo indicates that the
tree should be created relative to the root.
Serializes a UrlTree into a string
@returnsstring
Returns whether the url is activated.
@deprecated
Use IsActiveMatchOptions instead.
- The equivalent
IsActiveMatchOptionsfortrueis{paths: 'exact', queryParams: 'exact', fragment: 'ignored', matrixParams: 'ignored'}. - The equivalent for
falseis{paths: 'subset', queryParams: 'subset', fragment: 'ignored', matrixParams: 'ignored'}.
@returnsboolean
@deprecated
- Use the
isActivefunction instead.
@returnsboolean