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.

[selected] property for mat-option element

See original GitHub issue

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?

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:9

github_iconTop GitHub Comments

1reaction
Anzil-Aufaitcommented, May 21, 2019

I want to set <mat-select multiple> one option to default checked.

Read more comments on GitHub >

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

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