// create /team/33/user/11
router.createUrlTree(['/team',33,'user',11]);// create /team/33;expand=true/user/11
router.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 node
router.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/details
router.createUrlTree(['details'],{relativeTo: route});// navigate to /team/33/user/22
router.createUrlTree(['../22'],{relativeTo: route});// navigate to /team/44/user/22
router.createUrlTree(['../../team/44/user/22'],{relativeTo: route});
router.navigate(['team',33,'user',11],{relativeTo: route});// Navigate without updating the URL
router.navigate(['team',33,'user',11],{relativeTo: route, skipLocationChange:true});
In opposite to navigateByUrl, navigate always takes a delta that is applied to the current URL.
A handler for errors thrown by Router.parseUrl(url) when url contains an invalid character. The most common case is a % sign that's not encoded and is not part of a percent encoded sequence.
How to handle a navigation request to the current URL. One of:
'ignore' : The router ignores the request.
'reload' : The router reloads the URL. Use to implement a "refresh" feature.
paramsInheritanceStrategy: 'emptyOnly' | 'always'
How to merge parameters, data, and resolved data from parent to child routes. One of:
'emptyOnly' : Inherit parent parameters, data, and resolved data for path-less or component-less routes.
'always' : Inherit parent parameters, data, and resolved data for all child routes.
urlUpdateStrategy: 'deferred' | 'eager'
Determines when the router updates the browser URL. By default ("deferred"), updates the browser URL after navigation has finished. Set to 'eager' to update the browser URL at the beginning of navigation. You can choose to update early so that, if navigation fails, you can show an error message with the URL that failed.
relativeLinkResolution: 'legacy' | 'corrected'
Enables a bug fix that corrects relative link resolution in components with empty paths.
When given an activated route, applies the given commands starting from the route. Otherwise, applies the given command starting from the root.
Usage Notes
// create /team/33/user/11
router.createUrlTree(['/team',33,'user',11]);// create /team/33;expand=true/user/11
router.createUrlTree(['/team',33,{expand:true},'user',11]);// you can collapse staticsegments 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 node
router.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/details
router.createUrlTree(['details'],{relativeTo: route});// navigate to /team/33/user/22
router.createUrlTree(['../22'],{relativeTo: route});// navigate to /team/44/user/22
router.createUrlTree(['../../team/44/user/22'],{relativeTo: route});
An object containing properties that modify the navigation strategy. The function ignores any properties in the NavigationExtras that would change the provided URL.
Optional. Default is { skipLocationChange: false }.
Returns
Promise<boolean>: A Promise that resolves to 'true' when navigation succeeds, to 'false' when navigation fails, or is rejected on error.
Usage Notes
router.navigateByUrl("/team/33/user/11");// Navigate without updating the URL
router.navigateByUrl("/team/33/user/11",{ skipLocationChange:true});
Optional. Default is { skipLocationChange: false }.
Returns
Promise<boolean>
Returns a promise that:
resolves to 'true' when navigation succeeds,
resolves to 'false' when navigation fails,
is rejected when an error happens.
Usage Notes
router.navigate(['team',33,'user',11],{relativeTo: route});// Navigate without updating the URL
router.navigate(['team',33,'user',11],{relativeTo: route, skipLocationChange:true});
The first parameter of navigate() is a delta to be applied to the current URL or the one provided in the relativeTo property of the second parameter (the NavigationExtras).
In order to affect this browser's history.state entry, the state parameter can be passed. This must be an object because the router will add the navigationId property to this object before creating the new history item.