2016-10-03 15 views
1

ng-modelとselect itemの間の大文字小文字を無視する方法はありますか?UI-Select case Insensitive

この問題はlog.usernameがドロップダウンではなく入力ボックスだったので、古いユーザー名はすべて大文字と小文字を区別しています。

例:= "doej"

log.username。

lookupOptions.users = [{ユーザー名: "DoeJ" のfullName: "ジョー・ドウ"}、 {ユーザー名: "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> 
+0

NG・リピート= "lookupOptions.usersのオプションとしてオプション" で、それが働いていますか? – Wandrille

+0

残念ながらng-modelは正確な文字列値を探します。したがって、selectは空になり、それ以外の場合は '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>