Unable to set 'selected' attribute on md-option
See original GitHub issueUnable to set ‘selected’ attribute on md-option
Receiving the following error: Can’t bind to ‘selected’ since it isn’t a known property of ‘md-option’.
Code sample:
<md-select [placeholder]="'Status'">
<md-option *ngFor="let statusType of viewModel.StatusTypes" value="{{statusType.Id}}" (onSelect)="statusSelectionChange(statusType)" [selected]="statusType.Id == -10">
{{statusType.Value}}
</md-option>
</md-select>
Issue Analytics
- State:
- Created 7 years ago
- Comments:16 (2 by maintainers)
Top Results From Across the Web
angularjs - md-select can't set selected value - Stack Overflow
The documentation isn't explicit, but you should use ng-selected . I've created a codepen to illustrate, but basically: <md-option ng-repeat="(index,item) ...
Read more ><select>: The HTML Select element - HTML - MDN Web Docs
You can include a selected attribute on an <option> element to make it selected by default when the page first loads. The <select>...
Read more >Directives > mdOption - AngularJS Material
If the attribute exists, mark the option as "empty" allowing the option to clear the select and put it back in it's default...
Read more >can't bind to 'selected' since it isn't a known property of 'mat ...
Unable to set 'selected' attribute on md-option. Receiving the following error: Can't bind to 'selected' since it isn't a known property of 'md-option'....
Read more >Angularjs – md-select can't set selected value - iTecNote
I have a md-select set up as follows: <md-select placeholder="Category" ng-model="current.Category" flex > <md-option ng-repeat="item in categories" ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@kara Can you explain why this isn’t needed? How would one initialize
md-option
wheremultiple
checked options are permitted?Thanks,
I was stuck with this solution initially because I wasn’t binding to the value attribute of md-option
i.e. [value]=“statusType.Id” vs. value=“{{statusType.Id}}”
In case anyone else stumbles upon this thread.