繁体   English   中英

angular-ui / ui-select下拉列表开头为

[英]angular-ui/ui-select dropdown start with

是否有可能按开始显示向下倾斜的项目?

我正在使用此https://github.com/angular-ui/ui-select ,从下拉列表中,如果我写“ a”,则显示所有带有“ a”的单词

我只想显示以“ a”开头的单词

有指令https://github.com/angular-ui/ui-select/wiki/ui-select-match ,但无法弄清楚该怎么做

http://embed.plnkr.co/WyIC087njDHLmIVGTAj7/preview

我想在angular.js中做同样的事情: Select2 jQuery插件:有没有一种方法可以按字母顺序对标签列表进行排序?

您可能需要稍微调整一下,但是...

您可以编写一个自定义过滤器函数,如果第一个字符为“ a”,则返回true:

    <ui-select ng-model="card.id">
    <ui-select-match>{{$select.selected.name}}</ui-select-match>
    <ui-select-choices repeat="item.id as item in users | filter:criteriaMatch($select.search)">
        <div ng-bind-html="item.name | highlight: $select.search"></div>
    </ui-select-choices>
</ui-select>

然后在javascript中执行以下操作:

$scope.criteriaMatch = function( s ) {
  return function(val) {
    val.charAt(0) == s;
  }
};

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM