2016-10-03 59 views
1

有什么办法可以忽略ng模型和选择项目之间的情况吗?UI选择案例不敏感

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

实施例:

log.username = “doej”;

lookupOptions.users = [{用户名: “DoeJ”,全名: “乔Doe的”},{ 用户名: “SmithM”,全名: “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> 
+0

与NG-重复= “选项,如lookupOptions.users选项”,在它的工作? – Wandrille

+0

不幸的是,ng-model会查找确切的字符串值。所以,选择将是空的,否则'log.username ='DoeJ'' – gilango

回答

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>