2020-10-12 11:13:57 -07:00
|
|
|
## Router's NavigationExtras.preserveQueryParams migration
|
|
|
|
|
|
|
|
Previously the `NatigationExtras` property of `preserveQueryParams` defined what should be done with
|
|
|
|
query parameters on navigation. This migration updates the usages of `preserveQueryParams` to
|
2020-11-19 17:21:51 +01:00
|
|
|
instead use the `queryParamsHandling` property.
|
2020-10-12 11:13:57 -07:00
|
|
|
|
|
|
|
#### Before
|
|
|
|
```ts
|
|
|
|
import { Component } from '@angular/core';
|
|
|
|
import { Router } from '@angular/router';
|
|
|
|
|
|
|
|
@Component({})
|
|
|
|
export class MyComponent {
|
|
|
|
constructor(private _router: Router) {}
|
|
|
|
|
|
|
|
goHome() {
|
|
|
|
this._router.navigate('/', {preserveQueryParams: true, skipLocationChange: 'foo'});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
#### After
|
|
|
|
```ts
|
|
|
|
import { Component } from '@angular/core';
|
|
|
|
import { Router } from '@angular/router';
|
|
|
|
|
|
|
|
@Component({})
|
|
|
|
export class MyComponent {
|
|
|
|
constructor(private _router: Router) {}
|
|
|
|
|
|
|
|
goHome() {
|
2020-11-19 17:21:51 +01:00
|
|
|
this._router.navigate('/', { queryParamsHandling: 'preserve', skipLocationChange: 'foo' });
|
2020-10-12 11:13:57 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
```
|