Skip to content

ngValue ignored in ng-content and ng-template #26273

@mjswensen

Description

@mjswensen

I'm submitting a...


[ ] Regression (a behavior that used to work and stopped working in a new release)
[x] Bug report  
[ ] Performance issue
[x] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead see https://github.com/angular/angular/blob/master/CONTRIBUTING.md#question
[ ] Other... Please describe:

This issue was previously reported at #22374, which was closed as a support request even though I don't believe it was intended to be one.

Current behavior

ngValue is ignored if (1) the <option>s are provided via <ng-content> to a component (even if the component simply wraps a vanilla <select>) or (2) if the <option>s are in an <ng-template>.

Expected behavior

ngValue should work the same in these cases as it does when using a plain <select> with directly nested <option>s.

Minimal reproduction of the problem with instructions

Please see https://codesandbox.io/s/2z2n2v0pjp .

Here is a screenshot of the reproduction:

image

What is the motivation / use case for changing the behavior?

Many applications require a custom-styled <select> component that allow the caller of the component to provide their own <option>s.

Environment


Angular version: 6

Browser:
- [x] All

Metadata

Metadata

Assignees

Labels

area: formsfeatureIssue that requests a new featurefeature: under considerationFeature request for which voting has completed and the request is now under considerationfreq2: medium

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions