angular-docs-cn/packages/core/schematics/migrations/router-preserve-query-params
Kristiyan Kostadinov 1a26f6da6e fix(core): migration error if program contains files outside of the project (#39790)
Currently all of our migrations are set up to find the tsconfig paths within a project,
create a `Program` out of each and migrate the files inside of the `Program`. The
problem is that the `Program` can include files outside of the project and the CLI
APIs that we use to interact with the file system assume that all files are within
the project.

These changes consolidate the logic, that determines whether a file can be migrated,
in a single place and add an extra check to exclude files outside of the root.

Fixes #39778.

PR Close #39790
2020-11-20 12:51:19 -08:00
..
BUILD.bazel
README.md fix(router): migration incorrectly replacing deprecated key (#39763) 2020-11-19 09:08:10 -08:00
index.ts fix(core): migration error if program contains files outside of the project (#39790) 2020-11-20 12:51:19 -08:00
util.ts fix(router): migration incorrectly replacing deprecated key (#39763) 2020-11-19 09:08:10 -08:00

README.md

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 instead use the queryParamsHandling property.

Before

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

import { Component } from '@angular/core';
import { Router } from '@angular/router';

@Component({})
export class MyComponent {
  constructor(private _router: Router) {}

  goHome() {
    this._router.navigate('/', { queryParamsHandling: 'preserve', skipLocationChange: 'foo' });
  }
}