2016-09-07 11 views
1

enter image description here私は以下のコードを持っています。 私は物語の所有者と物語の状態を使用しています。htmlで複数の条件にフィルタを書き込む方法は?

ng-repeat="item in IterationStories | 
filter: {Story: {storyOwner: filterRequestor}} | 
filter: {Story: {state: filterKey}} " //when I select state it is working 
+0

あなたがより簡単に指定できます。

{ storyOwner: 'something', state: 'deleted', } 

をあなたはこのようなフィルタを実装することができますあなたの問題について正しく質問を正式化してください。 –

+0

あなたの条件をチェックするカスタム関数でフィルタを使用することができます この回答を見る:http://stackoverflow.com/questions/16474091/angularjs-custom-filter-function –

+0

これは、それらを個別に処理するので、条件1の結果をフィルタリングし、条件2の2番目のフィルタを使用して結果を実行します。 – ste2425

答えて

1

公式の角度フィルタドキュメントhereには良い例があります。

だからあなたの "アイテム" オブジェクトは次のようになり場合:

<label>Story owner <input ng-model="search.storyOwner"></label> 
<label>State <input ng-model="search.state"></label> 
<table> 

    <tr ng-repeat="item in IterationStories | filter:search"> 

    </tr> 
</table> 
+0

こんにちは、私はチェックボックスのフィルタ検索ボックスを使用していません。 –

0

//for third solution 
 
    $scope.myFilter = function (item) { 
 
     return (item.storyOwner == $scope.Story.storyOwner || item.state:$scope.Story.filterKey); 
 
    }
<!--first solution--> 
 
    ng-repeat="item in IterationStories | filter:{storyOwner: filterRequestor, state: filterKey} " 
 

 
<!--second solution--> 
 
    ng-repeat="item in IterationStories | filter: {Story: {storyOwner: filterRequestor, state: filterKey}}" 
 

 
<!--third solution--> 
 
    ng-repeat="item in IterationStories | filter:myFilter"

+0

データを書き込む(json)ことができますか? –

+0

こんにちはbaris ciraci、私もこれらのすべてのソリューションを試してみました。私はHTMLでのみjsonをフィルタリングしたくありません。 –

+0

データをフィルタリングしたいのですか? –

関連する問題