Skip to content

refactor(core): Deprecate the ngIf/ngFor/ngSwitch structural directives#60492

Closed
JeanMeche wants to merge 2 commits intoangular:mainfrom
JeanMeche:deprecation-🚀

Hidden character warning

The head ref may contain hidden characters: "deprecation-\ud83d\ude80"
Closed

refactor(core): Deprecate the ngIf/ngFor/ngSwitch structural directives#60492
JeanMeche wants to merge 2 commits intoangular:mainfrom
JeanMeche:deprecation-🚀

Conversation

@JeanMeche
Copy link
Copy Markdown
Member

@JeanMeche JeanMeche commented Mar 20, 2025

The control flow @-blocks have been introduced in v17.
As an effort to unify & streamline template authoring, we are deprecating in v20 the structural directives ngIf/ngFor/ngSwitch.

The control flow schematics becomes a migration that is executed during ng update

Note: This is not a deprecation of structural directives, this only about ngIf/ngFor/ngSwitch.

DEPRECATION: ngIf/ngFor/ngSwitch are deprecated. Use the control flow blocks instead (@for/@if/@switch).


If you're looking for argument for not keeping both control flow:

@angular-robot angular-robot bot added the area: core Issues related to the framework runtime label Mar 20, 2025
@ngbot ngbot bot added this to the Backlog milestone Mar 20, 2025
@JeanMeche JeanMeche force-pushed the deprecation- branch 5 times, most recently from d3649bd to 5020395 Compare March 20, 2025 17:46
@angular-robot angular-robot bot added the detected: deprecation PR contains a commit with a deprecation label Mar 20, 2025
@JeanMeche JeanMeche force-pushed the deprecation- branch 2 times, most recently from 3301c4a to 73a2608 Compare March 20, 2025 18:12
@JeanMeche JeanMeche changed the title refactor(core): Deprecate the structural directives ngIf/ngFor/ngSwitch refactor(core): Deprecate the ngIf/ngFor/ngSwitch structural directives Mar 20, 2025
@JeanMeche JeanMeche force-pushed the deprecation- branch 2 times, most recently from 2c71cdf to fc50c52 Compare March 21, 2025 02:00
@JeanMeche JeanMeche marked this pull request as ready for review March 21, 2025 02:04
@JeanMeche JeanMeche force-pushed the deprecation- branch 6 times, most recently from 7da3213 to ec160b2 Compare March 21, 2025 08:37
Copy link
Copy Markdown
Member

@pkozlowski-opensource pkozlowski-opensource left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Reviewed-for: public-api
Reviewed-for: fw-general

Copy link
Copy Markdown
Member

@alxhub alxhub left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed-for: public-api

@pkozlowski-opensource pkozlowski-opensource added the action: presubmit The PR is in need of a google3 presubmit label Mar 24, 2025
@pkozlowski-opensource pkozlowski-opensource removed the request for review from thePunderWoman March 24, 2025 14:13
@thePunderWoman thePunderWoman added the target: major This PR is targeted for the next major release label Mar 24, 2025
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will run the control flow migration automatically on ng update which users might not be prepared for. Should this be an optional migration so they get prompted to run it?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is what we decided in the last fw sync. We can rediscuss this if needed.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was under the impression that we decided to prompt users to migrate. There would likely be another migration once we actually remove the symbols.

…gSwitch`.

Note: This is not a deprecation of structural directives, this only about  `ngIf`/`ngFor`/`ngSwitch`.

DEPRECATED: `ngIf`/`ngFor`/`ngSwitch` are deprecated. Use the control flow blocks instead (`@for`/`@if`/`@switch`).
@DaSchTour
Copy link
Copy Markdown

What about self build structural directives that use ngIf as a base. They will have to copy extract the code from angular and move them to their own code base. It really feels wrong to be that there is so much effort put into new shiny stuff and removal of known working things. With class based guards and resolvers there was already massive backlash but it looks like the path of throwing things away is still followed.

The migration had to be run manually before this change. It is now part of the update process when migrating to v20.
@JeanMeche JeanMeche added action: merge The PR is ready for merge by the caretaker merge: caretaker note Alert the caretaker performing the merge to check the PR for an out of normal action needed or note and removed action: presubmit The PR is in need of a google3 presubmit labels Mar 28, 2025
@JeanMeche
Copy link
Copy Markdown
Member Author

JeanMeche commented Mar 28, 2025

Caretaker note: cl/740341215 needs to get in with this PR.

thePunderWoman pushed a commit that referenced this pull request Mar 28, 2025
…0492)

The migration had to be run manually before this change. It is now part of the update process when migrating to v20.

PR Close #60492
@thePunderWoman
Copy link
Copy Markdown
Contributor

This PR was merged into the repository by commit e40b5c9.

The changes were merged into the following branches: main

@angular-automatic-lock-bot
Copy link
Copy Markdown

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Apr 28, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

action: merge The PR is ready for merge by the caretaker area: core Issues related to the framework runtime detected: deprecation PR contains a commit with a deprecation merge: caretaker note Alert the caretaker performing the merge to check the PR for an out of normal action needed or note target: major This PR is targeted for the next major release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants