UI-Select案例不敏感

时间:2016-10-03 18:30:34

标签: angularjs angular-ui-select

有没有办法忽略ng-model和select item之间的情况?

我遇到的这个问题是log.username是一个输入框而不是下拉列表,所以旧的用户名都有不同的情况。

  

示例:

     

log.username =“doej”;

     

lookupOptions.users = [{username:“DoeJ”,fullName:“Joe Doe”},   {username:“SmithM”,fullName:“MarySmith”}]

     

在加载时,选择为空而不是“DoeJ”

 <div class="form-group col-md-4">
        <label>Stored By</label>
        <ui-select ng-model="log.username" theme="bootstrap">
            <ui-select-match placeholder="Select Site">{{$select.selected.username}}</ui-select-match>
            <ui-select-choices repeat="option.username as option in lookupOptions.users | orderBy: 'username' | propsFilter: {'username':  $select.search}">
                <div ng-bind-html="option.username | highlight: $select.search"></div>
                <small ng-bind-html="option.fullName | highlight: $select.search"></small>
            </ui-select-choices>
        </ui-select>
    </div>

1 个答案:

答案 0 :(得分:0)

这就是我所做的:

控制器:

log.username = log.username ? log.username.toLowerCase() : ""; 

查看:

    <div class="form-group col-md-4">
        <label>Stored By</label>
        <ui-select ng-model="log.username" theme="bootstrap">
            <ui-select-match placeholder="Select Site">{{$select.selected.username}}</ui-select-match>
            <ui-select-choices repeat="option.username.toLowerCase() as option in lookupOptions.users | orderBy: 'username' | propsFilter: {'username':  $select.search}">
                <div ng-bind-html="option.username | highlight: $select.search"></div>
                <small ng-bind-html="option.fullName | highlight: $select.search"></small>
            </ui-select-choices>
        </ui-select>
    </div>