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

Hiblton picture Hiblton  路  3Comments

jelbourn picture jelbourn  路  3Comments

xtianus79 picture xtianus79  路  3Comments

3mp3ri0r picture 3mp3ri0r  路  3Comments

theunreal picture theunreal  路  3Comments