2016-06-28 6 views
4

私がangular-ui-selectを使用して、ブートストラップモーダルウィンドウの〜1500個のリストのリストを使用しているとき、angle-ui-selectのドロップダウンリストの動作が遅い。Modalのアイテムの大きなリスト

ユーザーが行うすべての操作に2秒の遅延があります。 'minimum-input-length'を使用してパフォーマンスを向上させようとしましたが、フィルターが機能しません。

Plunkr例: https://plnkr.co/edit/H0kbeR4kHfZFjsBnpjBC?p=preview

MY HTML:

<ui-select multiple sortable="true" ng-model="vm.selected" theme="select2" style="width: 100%;"> 
       <ui-select-match placeholder="Select...">{{ $item.name }}</ui-select-match> 
       <ui-select-choices repeat="item in vm.items | filter: $select.search" minimum-input-length="2"> 
       <div ng-bind-html="item.name | highlight: $select.search"></div> 
       </ui-select-choices> 
      </ui-select> 
  1. 誰もがパフォーマンスを向上させる方法を知っていますか?
  2. 適用方法最小文字フィルタ?

    ありがとうございました。

答えて

11

をトリガされ、私は、LimitToを使用して検索の長さをチェックすることを解決:

limitTo: ($select.search.length <= 2) ? 0 : undefined" 

完全なコード:

<ui-select-choices 
    repeat="item in ctrl.items | filter: $select.search | limitTo: ($select.search.length <= 2) ? 0 : undefined"> 
+0

これは完全に機能しました! – badigard

+0

または別の方法を使用することもできます。 https://github.com/Modulr/mdr-angular-select2 – Gery

+0

すごい!魔法のように働く –

1

私は最小限の長さがリフレッシュ機能の使用でのみ動作すると考えています。 多くの問題があるため、パフォーマンスはまだ問題です。リフレッシュ機能の前に必要な

Documentation of uiselect

最小の文字が

+0

「リフレッシュ」機能は、データソースを$ httpリクエストとして定義するためのものです。私の例では、私はすでにすべてのデータをローカル変数に格納しています。 – badigard

+0

これは正しいですが、「最小入力長」はリフレッシュ機能でのみ機能します。 (私の知る限りでは)。 uiの一部のコードでは、最小の入力長がリフレッシュ機能を起動することがわかります。 if(!attrs.minimumInputLength || $ select.search.length> = attrs.minimumInputLength){ $ select.refresh(attrs.refresh); } – Jefiozie

+0

だから、リストから項目を選択するための別のライブラリを見つけようとするのがよいでしょうか? – badigard

関連する問題