我使用的是ui-select。
<ui-select id="ItemId" ng-model="ctrl.ItemId" theme="bootstrap"
ng-disabled="ctrl.DownDisabled" required>
<ui-select-match placeholder={{ctrl.Placeholder}}>{{$select.selected.item}}
</ui-select-match>
<ui-select-choices
repeat="item in ctrl.owners.components">
<div ng-bind-html="item | highlight: $select.search"></div>
</ui-select-choices>
<ui-select-no-choice>
No features were found
</ui-select-no-choice>
</ui-select>
它遍历的JSON是
ctrl.owners = {
value : 123,
teamName : ABC,
components : [a,b,c]
};
但是UI下拉菜单显示"没有找到任何功能"。问题是什么?我的目标是在下拉菜单中将components
显示为单个选项。我想这需要以某种方式通过在ui-select-choices
中使用嵌套重复来完成。我怎么能做到呢?
<div class="form-group ">
<ui-select ng-model="person.selected" theme="bootstrap">
<ui-select-match placeholder="Select or search a person in the list...">{{$select.selected.name}}</ui-select-match>
<ui-select-choices repeat="item in people | filter: $select.search">
<div ng-bind-html="trustAsHtml((item.name | highlight: $select.search))"></div>
<small ng-bind-html="trustAsHtml((item.email | highlight: $select.search))"></small>
</ui-select-choices>
</ui-select>
</div>
$scope.people = [
{ name: 'Adam', email: 'adam@email.com', age: 12, country: 'United States' },
{ name: 'Amalie', email: 'amalie@email.com', age: 12, country: 'Argentina' }];
你可以像这样使用它会工作。此处trustashhtml为方法。
$scope.trustAsHtml = function(value) {
return $sce.trustAsHtml(value);
};