1

enter image description hereI have the code given below. I am using story owner and story state.

ng-repeat="item in IterationStories | 
filter: {Story: {storyOwner: filterRequestor}} | 
filter: {Story: {state: filterKey}} " //when I select state it is working
  • Can you be more brief about your problem and formalize your question properly? – Nishi Bangar Sep 07 '16 at 08:01
  • you can use filter with a custom function where you check your conditions have a look at this answer: http://stackoverflow.com/questions/16474091/angularjs-custom-filter-function – Massimo Rosin Sep 07 '16 at 08:07
  • That is applying two separate filters chaining them individually, so it will filter your results with condition one, run the results through a second filter with condition two etc. – ste2425 Sep 07 '16 at 08:23
  • hi ste2425, Like you said it is executing the first one and later the second but i dono how to move to first one. – Hariprasath.r Sep 08 '16 at 14:17
  • Can you give us IterationStories json data? – barış çıracı Sep 09 '16 at 05:52

2 Answers2

1

You find a good example on the official Angular filter documentation here.

So if your "item" object look like this:

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

You can implement the filter like this:

<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>
Robert Sandu
  • 673
  • 1
  • 6
  • 15
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"
barış çıracı
  • 1,033
  • 14
  • 16