我有一些用ng-repeat标签显示的员工。我想将过滤器应用于五列中的两列。 Employee对象的JSON如下:
Employee: {
"name" : "John Arya",
"age" : "45",
"gender" : "male",
"salary" : "4500",
"designation" : "analyst",
"address" : {
"houseno" : "101",
"street" : "bakers street",
"landmark": "Near Mail office",
"city": "london",
"areacode": "zte190"
}
}
我有5列用于显示员工详细信息, 姓名,性别,薪水,职务和城市。
我想在GENDER和CITY列的顶部应用select,以便我可以过滤出结果并进行分析。
下面是我的代码。
<select ng-model="genderValue">
<option value="">ALL</option>
<option value="male">MALE</option>
<option value="female">FEMALE</option>
<select ng-model="cityValue">
<option value="">ALL</option>
<option ng-repeat="city in cityList" value="{{city.value}}">{{city.name}}
</option>
我正在显示如下员工列表。
<div ng-repeat="employee in employees | filter: {gender: genderValue,
address.city: cityValue"} >
// Code display employee details
</div>
每当我选择任何城市时,都应根据所选城市以及类似的性别来过滤员工列表。但我无法实现这一目标。我在IntelliJ中收到“ Statement Expected”的错误提示。而且它不起作用。我做错了什么?请告知是否有其他方法可以达到相同的效果,即在ng-repeat中多次应用多个内置$ filter。