admin管理员组文章数量:1391964
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;
},
本文标签: javascriptPolymer option selectedStack Overflow
版权声明:本文标题:javascript - Polymer option selected - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744600981a2615062.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论