What it does
Represents the extra options used during navigation.
Interface Overview
interface NavigationExtras {relativeTo: ActivatedRoute
queryParams: Params
fragment: string
preserveQueryParams: boolean
queryParamsHandling: QueryParamsHandling
preserveFragment: boolean
skipLocationChange: boolean
replaceUrl: boolean
}
Interface Description
Interface Details
relativeTo : ActivatedRouteEnables relative navigation from the current ActivatedRoute.
Configuration:
[{path: 'parent',component: ParentComponent,children: [{path: 'list',component: ListComponent},{path: 'child',component: ChildComponent}]}]
Navigate to list route from child route:
@Component({...})class ChildComponent {constructor(private router: Router, private route: ActivatedRoute) {}go() {this.router.navigate(['../list'], { relativeTo: this.route });}}
queryParams : ParamsSets query parameters to the URL.
// Navigate to /results?page=1this.router.navigate(['/results'], { queryParams: { page: 1 } });
fragment : stringSets the hash fragment for the URL.
// Navigate to /results#topthis.router.navigate(['/results'], { fragment: 'top' });
preserveQueryParams : booleanPreserves the query parameters for the next navigation.
deprecated, use queryParamsHandling instead
// Preserve query params from /results?page=1 to /view?page=1this.router.navigate(['/view'], { preserveQueryParams: true });
queryParamsHandling : QueryParamsHandlingconfig strategy to handle the query parameters for the next navigation.
// from /results?page=1 to /view?page=1&page=2this.router.navigate(['/view'], { queryParams: { page: 2 }, queryParamsHandling: "merge" });
preserveFragment : booleanPreserves the fragment for the next navigation
// Preserve fragment from /results#top to /view#topthis.router.navigate(['/view'], { preserveFragment: true });
skipLocationChange : booleanNavigates without pushing a new state into history.
// Navigate silently to /viewthis.router.navigate(['/view'], { skipLocationChange: true });
replaceUrl : booleanNavigates while replacing the current state in history.
// Navigate to /viewthis.router.navigate(['/view'], { replaceUrl: true });
exported from router/index, defined in router/src/router.ts