Jose Jose - 4 months ago 10
AngularJS Question

AngularJS: Filtering results with two parameters taken from inputs

I have this simple Angular app which displays movies in table format and has a search input and dropdown (select element) with genre values to filter/search results. I am trying to figure out how I can filter my results by both terms typed into the search input AND the dropdown.

JSBin

Whenever a value is selected from the dropdown, you will see the console log

$scope.selectedValue
. Is there a way I can pass this to the search input (with an
ng-model="searchBar"
)?

Thanks in advance.

EDIT: Basically, I want to be able to filter my results by Genre if need be.

Answer

Just add another filter with the pipe. Like:

ng-repeat="movie in movies | filter:searchBar | filter: selectedGenre | orderBy:sortType:sortReverse"
Comments