I have an Angular 2 test app running the latest alpha (37). There are just three routes, that look like this:
@RouteConfig([
{ path: \'/\', component: Home
Updating for Angular 2:
To preserve query parameters present in the current url, add
// import NavigationExtras
import { NavigationExtras } from '@angular/router';
// Set our navigation extras object
// that contains our global query params
let navigationExtras: NavigationExtras = {
preserveQueryParams: true
};
// Navigate to the login page with extras
this.router.navigate(['/someLink'], navigationExtras);
For more info, check here:
This is fixed in Alpha 41. The query string is now persisted.
Try this this.router.navigate(['target'], {preserveQueryParams: true});