Skip to content

Comments

docs(cdk/coercion): add guidance on Angular built-in input transforms#32835

Open
yogeshwaran-c wants to merge 1 commit intoangular:mainfrom
yogeshwaran-c:docs/coercion-input-transforms
Open

docs(cdk/coercion): add guidance on Angular built-in input transforms#32835
yogeshwaran-c wants to merge 1 commit intoangular:mainfrom
yogeshwaran-c:docs/coercion-input-transforms

Conversation

@yogeshwaran-c
Copy link

What kind of change does this PR introduce?

Documentation improvement

What is the current behavior?

The CDK coercion documentation only shows the legacy pattern of using
coerceBooleanProperty and coerceNumberProperty with @Input() getters
and setters. It does not mention that Angular now provides built-in equivalents
(booleanAttribute and numberAttribute) that work with signal inputs.

Closes #27718

What is the new behavior?

Updates the coercion documentation to:

  • Add a comparison table showing CDK coercion functions and their Angular
    built-in equivalents (booleanAttribute, numberAttribute)
  • Recommend Angular's built-in transforms with signal inputs for new code
  • Show a modern example using input() with {transform: booleanAttribute}
    and {transform: numberAttribute}
  • Note that CDK-specific functions like coerceElement and coerceArray
    remain useful for custom coercion logic
  • Modernize the example code to use signal inputs

Additional context

Since Angular v16+, the transform option on @Input() made CDK coercion
less necessary for boolean and number inputs. Since Angular v17+, signal inputs
(input()) with transforms provide the cleanest API. The CDK coercion module
is still useful for coerceElement, coerceArray, and custom coercion logic.

@pullapprove pullapprove bot requested review from adolgachev and tjshiu February 23, 2026 20:38
@angular-robot angular-robot bot added area: docs Related to the documentation area: cdk/coercion labels Feb 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: cdk/coercion area: docs Related to the documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

docs-bug(coercion): Add a statement on how these functions relate to the Angular@^16 input transformers

1 participant