Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

selected attribute not working when formcontrol is on select tag #14116

Closed
stellasoft-will opened this issue Jan 26, 2017 · 9 comments
Closed

Comments

@stellasoft-will
Copy link

I'm submitting a ... (check one with "x")

[x ] bug report => search github for a similar issue or PR before submitting
[ ] feature request
[ ] support request => Please do not submit support request here, instead see https://github.com/angular/angular/blob/master/CONTRIBUTING.md#question

Current behavior

when adding selected attribute to an option tag the formControl attribute on the select tag prevents the option from being selected even though the dom has a selected value.

Expected behavior

would like when selected value is set to have that option set in the select drop down

Minimal reproduction of the problem with instructions

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

n/a
Please tell us about your environment:

webstrom, mac os, npm

  • Angular version: 2.0.X

2.3.1

  • Browser: [all | Chrome XX | Firefox XX | IE XX | Safari XX | Mobile Chrome XX | Android X.X Web Browser | iOS XX Safari | iOS XX UIWebView | iOS XX WKWebView ]

all

  • Language: [all | TypeScript X.X | ES6/7 | ES5]
    typescript
  • Node (for AoT issues): node --version =
    6.2.2
@DzmitryShylovich
Copy link
Contributor

It's by design. You can find an explanation here angular/components#2250 (comment)

@stellasoft-will
Copy link
Author

ok so what should this actually look like:

<select id="products" class="form-control new-select padding" formControlName="featured_product"> <option>Please Select</option> <option *ngFor="let p of products" [ngValue]="p" [attr.selected]="p.ProductId == product.ProductId ? '': null" >{{p.ProductName}}</option> </select>

@dmytro-y-dev
Copy link

nice, but why this PR is not still included?

@DzmitryShylovich
Copy link
Contributor

¯_(ツ)_/¯

@DzmitryShylovich
Copy link
Contributor

@metamaker it was merged

@dmytro-y-dev
Copy link

dmytro-y-dev commented Feb 1, 2017

@DzmitryShylovich Thx for info. I will wait for release with this PR included and then will update my package.json.

@pkozlowski-opensource
Copy link
Member

Fixed by f89d004

@angular-automatic-lock-bot
Copy link

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 Sep 10, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants