Hello i have a problem.
When i put an integer in ng-value, md-select is upadated:
<md-input-container>
<md-select ng-model="test">
<md-option ng-value="1">1</md-option>
<md-option ng-value="2">2</md-option>
<md-option ng-value="3">3</md-option>
<md-option ng-value="4">4</md-option>
</md-select>
</md-input-container>
But when i do this with string value it is not working, what can i do ?
<md-input-container>
<md-select ng-model="type">
<md-option ng-value=''></md-option>
<md-option ng-value='test' >test</md-option>
<md-option ng-value='test02'>test02</md-option>
<md-option ng-value='test03' >test03</md-option>
</md-select>
</md-input-container>
What's wrong ?
You can use value=""
(expect a string)
This is working:
<md-input-container>
<md-select ng-model="type">
<md-option value=''></md-option>
<md-option value='test' >test</md-option>
<md-option value='test02'>test02</md-option>
<md-option value='test03' >test03</md-option>
</md-select>
</md-input-container>
Or you can use ng-value=""
(expect an expression)
<md-input-container>
<md-select ng-model="type">
<md-option ng-value="''"></md-option>
<md-option ng-value="'test'" >test</md-option>
<md-option ng-value="'test02'">test02</md-option>
<md-option ng-value="'test03'" >test03</md-option>
</md-select>
</md-input-container>
Your first example is working because integer values are correct expressions. In your second example angular is looking for a property named test in your scope.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With