Skip to content

signal forms: support ngValue and compareWith for select #64670

@jnizet

Description

@jnizet

Which @angular/* package(s) are relevant/related to the feature request?

forms (signal)

Description

Unless I missed something, there doesn't seem to be a way to support binding a non-string value to a <select> element in signals form.

Proposed solution

It would be hugely useful if signal forms supported the same functionality as reactive forms regarding selects, namely ngValue on <option> elements, allowing to bind the option to any kind of value (typically objects with some identifier), and compareWith on <select> elements, allowing to specify that these objects must be compared to the current value of the control using a provided equality function.

Alternatives considered

Leave it as is, and force developers to bind to the identifier of the object, and have some computed signal outside of the form model that finds the object with the selected identifier inside the list of options, but that is not ideal IMHO.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions