Ionic /如何从选择控制中选择多个选项(最大选择将只有3个选项)
Ionic /How to select multiple options from select control(Maximum selection will 3 options only)?
我目前使用的是Ionic 1.3.16版本。这里我需要在选择控件中选择多个选项。
这是我的ionic HTML代码:
<div class="list">
<label class="item item-input item-select">
<div class="input-label">
Lightsaber
</div>
<select>
<option>Blue</option>
<option selected>Green</option>
<option>Red</option>
</select>
</label>
</div>
您在select
选项中缺少value
属性,因为当您选择选项时,它将反映到ng-model
。此外,要选择多个,您需要在选择中添加multiple
属性。
标记
<select ng-model="selectedValues" multiple>
<option ng-repeat="option in options" value="{{option.value}}">{{option.name}}</option>
</select>
{{selectedValues}}
只需在select字段中添加multiple
属性。
<div class="list">
<label class="item item-input item-select">
<div class="input-label">
Lightsaber
</div>
<select multiple="multiple">
<option>Blue</option>
<option selected>Green</option>
<option>Red</option>
</select>
</label>
使用ng-options来绑定数据,方法如下
控制器$scope.values= [
{id:1, name:"value1" },
{id:2, name:"value2" },
{id:3, name:"value3" }
];
$scope.selectedValues= []; //initial selections
和视图
<label class="item item-input item-select">
<select multiple ng-model='selectedValues'
ng-options="a.name for a in values" >
</select>
</label>
{{selectedValues}} <!-- to preview the selection -->
相关文章:
- CKeditor:更改对话框中的默认选择选项
- 如何在从多选下拉列表中选择选项值时动态生成文本框
- AngularJs列表ng单击以选择选项转换
- 使用基于文本的 Jquery 选择选项
- 当选择值x时,Javascript需要在正确的位置显示文本区域,从而循环通过具有选择选项的表单
- 在php和mysql中选择选项.一旦选择了选项,就列出我的sql数据库数据
- 选择选项时如何显示警报
- 使用php动态更改选择选项
- 选择“选择选项”时显示文本.怎么做
- LEAFLET地图和带有选择选项的标记-ANGULARjs
- 使用js将动态内容添加到选择选项列表中
- 用于使用javascript循环选择选项
- AngularJS-选择选项并在函数中使用它
- 禁用/启用基于单选/选择选项所选Javascript的文本框
- 如何使用jQuery隐藏与选择选项相关的选择选项列表
- 选择选项是添加或删除事件
- 使用jQuery向“选择选项”添加默认属性
- 构建HTML选择字段并使用JavaScript数组选择选项
- 带有动态选择选项的Firefox html5验证异常
- 只有当Angular从资源对象检索数据时,才选择选项元素