2016-05-03 7 views
0

、私は、https://tamtakoe.github.io/oi.select/#/select/#filteredダウンマルチ選択ドロップを使用しています次:フィルタリングマルチ選択のドロップダウンオプション私のangularjsアプリケーションで

<oi-multiselect ng-options="item.name for item in ins_Types " ng-model="insuranceTypes" multiple placeholder="Select" data-ng-required="true" name="insType" ></oi-multiselect > 

$scope.ins_Types = [{id: 1, name : "ins1"},{id: 2, name : "ins2"}, {id: 3, name : "ins3"}, {id: 4, name : "ins4"}]; 

をして、すべてのオプションのために正常に動作しています$scope.ins_Types。今度は、id < 3というオプションを表示するだけです。

<oi-multiselect ng-options="item.name for item in ins_Types | filter:{id < 3} " ng-model="insuranceTypes" multiple placeholder="Select" data-ng-required="true" name="insType" ></oi-multiselect > 

をしかし、それ以来、マルチ選択ドロップダウンが応答を停止し、オプションのいずれも表示されません取得されますので、以下に示すように、私はオプションにフィルタを使用しています。

私はさらに| filter:{item.id < 5}を試しましたが、それでも同じ問題があります。

答えて

1

あなたは

app.filter('myfilter', function() { 
    return function(input, condition) { 
    var filtered = []; 
    input.forEach(function(item, index) { 
     if (item.id > condition) { 
     filtered.push(item); 
     } 
    }); 
    return filtered; 
    }; 
}); 

のようなあなたの条件のためのカスタムフィルタを作成し、

<oi-select oi-options="item.name for item in ins_Types | myfilter : 3 track by item.id" ng-model="insuranceTypes" multiple placeholder="Select"></oi-select> 

ライブPlunker

はそれが役に立てば幸いようなあなたのマークアップでそれを使用することができます。

関連する問題