I am using Angular 2 with Angular Material. Looking at the documentation, I am trying to get the select to have a default value as oppose to an empty place holder.
I have tried the following two options and both of them does not set a default value
<md-select selected="1">
<md-option value="1" >One</md-option>
<md-option value="2">Two</md-option>
</md-select>
<md-select>
<md-option value="1" selected="true">One</md-option>
<md-option value="2">Two</md-option>
</md-select>
I looked at all the documentations and the examples, non of them helped
Best Answer
Use
[(ngModel)]
:Component:
selectedOption = '1';
DEMO
Edit #1:
Since Material2.0.0#beta10 (specifically this PR) you can select a value using the
value
property ofMatSelect
:Component:
selectedOption = '1';
Note that you can also use it with two-way data binding -> [(value)].
DEMO