Reputation: 831
I want to filter data on the basis of city dropdown alphabetical filter working fine but when i used dropdown and fiter dropdown selection then it will return wrong data please check my code here
[http://jsfiddle.net/Nayeem_Mansoori/yhy7hdrh/][1]
please help me.
Upvotes: 2
Views: 156
Reputation: 1425
When I want to filter one field only o do like it:
<li ng-repeat="cust in Customer | filter: { Name: myfilters } | orderBy: Name">{{cust.Name}}</li>
filter by properties use filter: { Name: myfilters }
http://jsfiddle.net/yhy7hdrh/4/
--- Some time later ---
I think I understand, chosing a city you want to filter by letter the Name of customer... http://jsfiddle.net/yhy7hdrh/8/
Upvotes: 1
Reputation: 21901
I think u made a smallllll mistake :)
use like this
<li ng-repeat="cust in Customer | filter: myfilters | orderBy: 'Name'">{{cust.Name}}</li>
please put the Name
as a string in orderBy as 'Name'
in order to filter by those two drop downs you need two separate filters, in angular its so simple as below line,
<li ng-repeat="cust in Customer | filter:selectedValue | filter:CityselectedValue | orderBy: 'Name'">
first it filter in selectedValue
which is the first dropdown, and the second filter filters the results according to second dropdown.
more specifically use can use like this,
first dropdown
<select ng-model="selectedValue.Name" n..
second dropdown
<select ng-model="selectedValue.City" ng-opti..
in ng-repeat
<li ng-repeat="cust in Customer | filter:selectedValue | orderBy: 'Name'">
Upvotes: 0