angular/packages/core/schematics/ng-generate/control-flow-migration
Kristiyan Kostadinov 71e0c7df69 fix(migrations): resolve infinite loop for a single line element with a long tag name and angle bracket on a new line (#54588)
Fixes an edge case where a single-line elemnt with a long tag name a closing bracket on a new line was putting the control flow migration into an infinite loop.

Fixes #54587.

PR Close #54588
2024-02-23 11:40:27 -08:00
..
BUILD.bazel feat(core): Add schematic to migrate control flow syntax (#52035) 2023-10-10 11:33:00 -07:00
cases.ts fix(migrations): cf migration validate structure of ngswitch before migrating (#53530) 2023-12-13 09:23:15 -08:00
fors.ts fix(migrations): Fix cf migration bug with parsing for loop conditions properly (#53558) 2023-12-14 09:33:27 -08:00
identifier-lookup.ts fix(migrations): cf migration - improve import declaration handling (#53622) 2023-12-18 22:10:58 +00:00
ifs.ts fix(migrations): cf migration - undo changes when html fails to parse post migration (#53530) 2023-12-13 09:23:14 -08:00
index.ts refactor: fix a number of typos throughout the codebase (#52826) 2024-01-25 22:54:59 +00:00
migration.ts fix(migrations): cf migration - detect and error when result is invalid i18n nesting (#53638) 2023-12-19 11:01:57 -08:00
README.md refactor(migrations): Add optional path param for control flow migration (#52403) 2023-10-27 15:15:22 -07:00
schema.json refactor(migrations): Switch control flow migration reformat default to true (#52971) 2023-11-16 11:16:30 -08:00
switches.ts fix(migrations): cf migration validate structure of ngswitch before migrating (#53530) 2023-12-13 09:23:15 -08:00
types.ts fix(migrations): cf migration - ensure full check runs for all imports (#53637) 2023-12-19 10:11:47 -08:00
util.ts fix(migrations): resolve infinite loop for a single line element with a long tag name and angle bracket on a new line (#54588) 2024-02-23 11:40:27 -08:00

Control Flow Syntax migration

Angular v17 introduces a new control flow syntax. This migration replaces the existing usages of *ngIf, *ngFor, and *ngSwitch to their equivalent block syntax. Existing ng-templates are preserved in case they are used elsewhere in the template. It has the following option:

  • path - Relative path within the project that the migration should apply to. Can be used to migrate specific sub-directories individually. Defaults to the project root.

NOTE: This is a developer preview migration

Before

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

@Component({
  template: `<div><span *ngIf="show">Content here</span></div>`
})
export class MyComp {
  show = false;
}

After

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

@Component({
  template: `<div>@if (show) {<span>Content here</span>}</div>`
})
export class MyComp {
  show = false
}