How do I set select option selected in Polymer 1.0?
<select id="typeSelect" style="width:100%;" value="{{item.type::change}}">
<option value="">Choose a type</option>
<template is="dom-repeat" items="{{types}}" as="type" >
<option selected?="{{type==item.type}}">{{type}}</option>
</template>
</select>
How do I set select option selected in Polymer 1.0?
<select id="typeSelect" style="width:100%;" value="{{item.type::change}}">
<option value="">Choose a type</option>
<template is="dom-repeat" items="{{types}}" as="type" >
<option selected?="{{type==item.type}}">{{type}}</option>
</template>
</select>
Share
Improve this question
edited Aug 26, 2015 at 16:43
user913129
asked Aug 26, 2015 at 16:10
user913129user913129
992 silver badges10 bronze badges
1 Answer
Reset to default 7You were very close. Use this.
<select id="typeSelect" style="width:100%;" value="{{item.type::change}}">
<option value="">Choose a type</option>
<template is="dom-repeat" items="{{types}}" as="type" >
<option selected$="{{selected(type,"yourtypetopare")}}">{{type}}</option>
</template>
</select>
Now, add a function in your polymer's element.
selected: function(item, type){
return type == item.type;
},