AngularJS ui-select下拉式默认值
AngularJS ui-select dropdown default value
我使用angular ui-select下拉菜单。如何为下拉值设置默认值?
<h3>Selectize theme</h3>
<p>Selected: {{country.selected}}</p>
<ui-select ng-model="country.selected" theme="selectize" ng-disabled="disabled" style="width: 300px;">
<ui-select-match placeholder="Select or search a country in the list...">{{$select.selected.name}}</ui-select-match>
<ui-select-choices repeat="country in countries | filter: $select.search">
<span ng-bind-html="country.name | highlight: $select.search"></span>
<small ng-bind-html="country.code | highlight: $select.search"></small>
</ui-select-choices>
</ui-select>
这个片段来自plnkr.co。目前下拉只是播种默认的Select or search a country in the list...
,但我需要从控制器传递一个值。比如$scope.default = {"name":"Decard"}
谢谢! !
编辑
这个问题与这个问题类似,但涉及json返回格式的数据
您可以将ng-model初始化为控制器中的默认国家对象,如下所示:
$scope.country = {};
$scope.country.selected = {name: 'Albania', code: 'AL'};
然后使用"ui-select-match"设置默认值,如下所示:
<ui-select ng-model="country.selected" theme="selectize" ng-disabled="disabled" style="width: 300px;">
<ui-select-match placeholder="Select or search a country in the list...">{{ $select.selected.name }}</ui-select-match>
<ui-select-choices repeat="country in countries | filter: $select.search">
<span ng-bind-html="country.name | highlight: $select.search"></span>
<small ng-bind-html="country.code | highlight: $select.search"></small>
</ui-select-choices>
</ui-select>
相关文章:
- Angularjs-设置不带ng选项的select的默认值
- 我正在使用角度 ui-select 进行下拉.如何在控制器中获取所选值
- JS:如果select是默认值,则禁用复选框
- AngularJS ui-select,如何初始化多选值
- 为什么不将 jQuery UI 日期选择器的默认值设置为匿名函数
- 如何设置角度 UI 选择的默认值
- 使用 ui-select 与 Angularjs 和 ajax 值
- 剑道 UI 组合框 - 设置默认值
- 使用默认选定的其他数据源时,从 ui-select 选项中删除重复项
- angularjs-lib中的一些prbm默认值在select if(value和name)相同时不起作用
- AngularJS-多重选择,动态设置默认值select
- 当通过AJAX绑定选项时,是否可以将select元素的默认值传递给Knockout
- Angular Js:您可以将select的默认值与使用'track by'在ng选项中
- 以前的值不会显示在Angular UI Select上
- 通过单击SELECT选项,将文本INPUT元素的VALUE动态设置为默认值
- 角度设置ui从另一个控制器中选择默认值
- jquery ui具有默认值和组合最大值的多个滑块
- jQuery UI滑块:具有默认值的多个滑块
- Select2.js设置默认值为带有输入数组的select box
- AngularJS ui-select下拉式默认值