Skip to content

feat(upgrade): add option to initialize inputs synchronously#69919

Open
rush1818 wants to merge 1 commit into
angular:mainfrom
rush1818:feat/upgrade-synchronous-input-bindings
Open

feat(upgrade): add option to initialize inputs synchronously#69919
rush1818 wants to merge 1 commit into
angular:mainfrom
rush1818:feat/upgrade-synchronous-input-bindings

Conversation

@rush1818

Copy link
Copy Markdown

Add initializeInputsSynchronously option to downgradeComponent to allow initializing Angular component inputs synchronously during creation.

Previously, downgraded components evaluated input bindings asynchronously during the first AngularJS digest cycle. This caused issues for components using input.required() signal inputs, which threw NG0950 errors if read during instantiation or initial rendering because the values were not yet available.

With this option enabled, the adapter uses ComponentRef.setInput() to apply bindings synchronously immediately after creation, ensuring required inputs are available before change detection runs.

Also fixes a bug in @angular/core where writeToDirectiveInput would crash when trying to read an undefined transform decorator on an input (common in JIT or manual mock inputs used in tests).

PR Checklist

Please check if your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Documentation content changes
  • angular.dev application / infrastructure changes
  • Other... Please describe:

What is the current behavior?

Downgraded Angular components evaluate their input bindings ($watch / $observe callbacks) asynchronously during the first AngularJS $digest cycle after component creation.

Because of this asynchronous initialization timing, if a downgraded component uses modern required signal inputs (input.required()), reading these signals during component instantiation or initial rendering/change detection throws error.

Issue Number: N/A

What is the new behavior?

  1. Adds a new configuration option initializeInputsSynchronously?: boolean (defaults to false) to downgradeComponent().
  2. When initializeInputsSynchronously is enabled (true), the downgraded component adapter evaluates the AngularJS input attributes/expressions and applies them synchronously using ComponentRef.setInput() immediately after component instantiation. This ensures that all inputs (including required signal inputs) are fully initialized before the initial change detection or rendering runs.

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

Add `initializeInputsSynchronously` option to `downgradeComponent` to allow initializing Angular component inputs synchronously during creation.

Previously, downgraded components evaluated input bindings asynchronously during the first AngularJS digest cycle. This caused issues for components using `input.required()` signal inputs, which threw `NG0950` errors if read during instantiation or initial rendering because the values were not yet available.

With this option enabled, the adapter uses `ComponentRef.setInput()` to apply bindings synchronously immediately after creation, ensuring required inputs are available before change detection runs.

Also fixes a bug in `@angular/core` where `writeToDirectiveInput` would crash when trying to read an undefined transform decorator on an input (common in JIT or manual mock inputs used in tests).
@pullapprove
pullapprove Bot requested a review from kirjs July 23, 2026 23:54
@angular-robot angular-robot Bot added detected: feature PR contains a feature commit area: upgrade Issues related to AngularJS → Angular upgrade APIs labels Jul 23, 2026
@ngbot ngbot Bot added this to the Backlog milestone Jul 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: upgrade Issues related to AngularJS → Angular upgrade APIs detected: feature PR contains a feature commit

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant