question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Unable to set 'selected' attribute on md-option

See original GitHub issue

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’.

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:closed
  • Created 7 years ago
  • Comments:16 (2 by maintainers)

github_iconTop GitHub Comments

8reactions
jackwoottoncommented, Apr 30, 2017

@kara Can you explain why this isn’t needed? How would one initialize md-option where multiple checked options are permitted?

8reactions
medeirosrichcommented, Dec 13, 2016

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found