angular/packages/core/schematics/migrations/control-flow-migration
Alan Agius 26fed34e0e
build: format md files
This commit configures prettier to format markdown files.
2025-11-06 10:03:05 -08:00
..
BUILD.bazel build: rename defaults2.bzl to defaults.bzl (#63383) 2025-08-25 15:45:01 -07:00
cases.ts refactor(migrations): centralize parseTemplate method (#62983) 2025-08-21 11:41:32 -07:00
fors.ts refactor(migrations): centralize parseTemplate method (#62983) 2025-08-21 11:41:32 -07:00
identifier-lookup.ts refactor(core): run the control flow migration during ng update (#60492) 2025-03-28 15:46:41 +00:00
ifs.ts refactor(migrations): centralize parseTemplate method (#62983) 2025-08-21 11:41:32 -07:00
index.ts fix(migrations): remove error for no matching files in control flow migration (#64253) 2025-10-06 15:29:25 -04:00
migration.ts refactor(migrations): centralize parseTemplate method (#62983) 2025-08-21 11:41:32 -07:00
README.md build: format md files 2025-11-06 10:03:05 -08:00
schema.json refactor(core): run the control flow migration during ng update (#60492) 2025-03-28 15:46:41 +00:00
switches.ts refactor(migrations): centralize parseTemplate method (#62983) 2025-08-21 11:41:32 -07:00
types.ts refactor(migrations): centralize parseTemplate method (#62983) 2025-08-21 11:41:32 -07:00
util.ts fix(migrations): Prevent removal of templates referenced with preceding whitespace characters 2025-11-04 23:25:59 +00: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.

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
}