在我的angularjs应用程序中,我使用的UI select.This是我的Html
<ui-select name="service" multiple ng-model="service.ServiceName" close-on-select="false" >
<ui-select-match placeholder="Select Services...">{{$item.ServiceName}}</ui-select-match>
<ui-select-choices repeat="service in Services | filter: {ServiceName: $select.search} | filter:myFilter track by service.ServiceId">
{{service.ServiceName}}
</ui-select-choices>Select filter提供了包含搜索的内容,但是我想根据StartsWith.I筛选元素,我已经看到了一些StartsWith.I的例子,但是我无法将它们合并到UI Select中。
发布于 2016-05-01 21:12:11
单项: Plunker.
JS
vm.startsWith = function (actual, expected) {
var lowerStr = (actual + "").toLowerCase();
return lowerStr.indexOf(expected.toLowerCase()) === 0;
}<ui-select-choices repeat="country in ctrl.countries|filter:$select.search:ctrl.startsWith">
<span ng-bind-html="country.name | highlight: $select.search"></span>
<small ng-bind-html="country.code | highlight: $select.search"></small>
</ui-select-choices>多项: Plunker
JS与上面的内容相同。
<ui-select multiple ng-model="ctrl.multipleDemo.colors" theme="bootstrap" ng-disabled="ctrl.disabled" close-on-select="false" style="width: 300px;" title="Choose a color">
<ui-select-match placeholder="Select colors...">{{$item}}</ui-select-match>
<ui-select-choices repeat="color in ctrl.availableColors | filter:$select.search : ctrl.startsWith">
{{color}}
</ui-select-choices>
</ui-select>https://stackoverflow.com/questions/36970946
复制相似问题