[selected] property for mat-option element
This 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?
i have the same problem @costea93 have you save this?
<mat-select [(value)]="selectedCode" formControlName="StatusCode">
<mat-option *ngFor="let status of statuses" [value]="status.Value" >
{{ status.Value }}
</mat-option>
</mat-select>`
Where selectedCode is selected object in statuses list, pay attention to [value] for mat-option
@sanidz this does not work
Sure? https://angular-hk47fh.stackblitz.io
https://stackblitz.com/edit/angular-hk47fh?file=app/select-overview-example.ts
Конечно? https://angular-hk47fh.stackblitz.io
https://stackblitz.com/edit/angular-hk47fh?file=app/select-overview-example.ts
how to make multiple advance selection?
Конечно? https://angular-hk47fh.stackblitz.io https://stackblitz.com/edit/angular-hk47fh?file=app/select-overview-example.ts
how to make multiple advance selection?
Not sure what do you mean by that, in dropdown only one element can be selected. If you want to do multiple selection, maybe check lists could do the trick. Could you explain your usecase in more details?
I want to set <mat-select multiple> one option to default checked.
The [value] attribute seems to only work if you're not using the formControlName directive. Currently facing the same issue. I have to manually use contol.setValue(value) in the component to update the view.
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.