[selected] property for mat-option element
See original GitHub issueThis is just an question or it might be an improvement.
I have this select component, and try select default an option from ngFor with [selected] property
`<mat-form-field>
<mat-select (change)="onSelect($event.target.value, question)">
<mat-option>{{'select' | translate}}</mat-option>
<mat-option *ngFor="let option of question.questionOptions"
[selected]="option.selected"
[value]="option.value">{{option.value}}</mat-option>
</mat-select>
</mat-form-field>`
but that won’t work because mat-option doesn’t have [selected] property. I know that i should add [selected] property to mat-select, but why not to have it to mat-option?
Issue Analytics
- State:
- Created 6 years ago
- Comments:9
Top Results From Across the Web
How to use Mat-Select with property [Selected] - Stack Overflow
First problem is, selected is not available for mat-option. What you need to do is, on your component.ts file you need to find...
Read more >Select | Angular Material
To add options to the select, add <mat-option> elements to the <mat-select> . Each <mat-option> has a value property that can be used...
Read more >Angular Material Select : Getting and Setting value
To add elements to select option, we need to use <mat-option> element. To bind value with <mat-option> , we need to use value...
Read more >Angular Material Select - Javatpoint
To add selection options, add <mat-select> elements to <mat-select>. Angular content supports the use of <mat-form-field> inside the native <select> element.
Read more >How To Set Default Value Of Mat Select When Options Are ...
Editor Preview Both. Sign in. Project. Search. Settings. Switch to Light Theme. Enter Zen Mode. Project. Download Project. Info. How To Set Default...
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
I want to set
<mat-select multiple>
one option to default checked.Sure? https://angular-hk47fh.stackblitz.io
https://stackblitz.com/edit/angular-hk47fh?file=app/select-overview-example.ts