mirror of
https://github.com/angular/angular
synced 2026-05-24 09:28:37 +00:00
Since Angular v15, the `RouterLink` contains the logic of the `RouterLinkWithHref` directive and now developers can always import and use the `RouterLink` directive when they need to add a `[routerLink]` in templates. This migration finds all imports and usages of the `RouterLinkWithHref` class and rewrites them to `RouterLink` instead.
```ts
import { RouterLinkWithHref } from '@angular/router';
@Component({
standalone: true,
template: `<a [routerLink]="'/abc'">`,
imports: [RouterLinkWithHref]
})
export class MyComponent {
@ViewChild(RouterLinkWithHref) aLink!: RouterLinkWithHref;
}
```
```ts
import { RouterLink } from '@angular/router';
@Component({
standalone: true,
template: `<a [routerLink]="'/abc'">`,
imports: [RouterLink]
})
export class MyComponent {
@ViewChild(RouterLink) aLink!: RouterLink;
}
```
PR Close #47599
|
||
|---|---|---|
| .. | ||
| tslint | ||
| typescript | ||
| BUILD.bazel | ||
| import_manager.ts | ||
| line_mappings.ts | ||
| load_esm.ts | ||
| ng_component_template.ts | ||
| ng_decorators.ts | ||
| parse_html.ts | ||
| project_tsconfig_paths.ts | ||
| template_ast_visitor.ts | ||