我使用angular来创建搜索属性表单,并且我有一个包含大量卧室的选择框,如何创建更大的过滤器? (例如:选择2间卧室时,显示2间卧室以上的所有房产)
选择框:
<select class="form-control"
name="bedrooms"
ng-model="Bedrooms"
ng-options="property.data.SubType as (property.data.Bedrooms + ' Bedrooms ('+ property.count +')') for property in properties | unique:'Bedrooms' | orderBy:'data.Bedrooms'">
<option value="">Minimum Bedrooms</option>
</select>
过滤器:
<tr ng-repeat="property in filtered = (properties | filterMultiple:{Address: Address, SubArea:SubArea, SubType:SubType} | filter:{Bedrooms:Bedrooms})| orderBy:Address">
这是我的JSFiddle
答案 0 :(得分:2)
http://jsfiddle.net/odpw6c6q/43/
在ng-options
中使用ng-options="property.data.Bedrooms as
代替ng-options="property.data.SubType as
因为data.Bedrooms
是包含应存储在ng-model
在范围内添加此功能
//Filter Function
$scope.greaterThan = function(bedrooms) {
return function(item) {
if ( item['Bedrooms'] > bedrooms) {
return true;
} else {
return false;
}
}
};
在ng-repeat
中使用filter: greaterThan(Bedrooms)
代替filter:{Bedrooms:Bedrooms}