Components: how to set selected option as default

Created on 26 Dec 2016  路  2Comments  路  Source: angular/components

how to set selected option as default

<md-select [(ngModel)]="selectedState" placeholder="State">
                <md-option *ngFor="let state of states" [value]="state.value">
                    {{state.title}}
                </md-option>
            </md-select>

Most helpful comment

Set the default value to selectedState. e.g:

states: any = [{value:0, title: 'Mac'}, {value:1, title:'Windows'}, {value: 2, title: 'Linux'}];
selectedState: number = 2;

All 2 comments

Set the default value to selectedState. e.g:

states: any = [{value:0, title: 'Mac'}, {value:1, title:'Windows'}, {value: 2, title: 'Linux'}];
selectedState: number = 2;

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

Was this page helpful?
0 / 5 - 0 ratings

Related issues

dzrust picture dzrust  路  3Comments

jelbourn picture jelbourn  路  3Comments

Miiekeee picture Miiekeee  路  3Comments

shlomiassaf picture shlomiassaf  路  3Comments

MurhafSousli picture MurhafSousli  路  3Comments