Reputation: 486
i am using ng-repeate and in my filter i need to use one of the fields in upper bounded list that can not be refrenced by inner select filter , so i need to set filters in html block and not in js file .somthing like this:
<div ng-repeat="groupfield in gCtrl.groupingFields">
<select ng-options="c.id as c.title for c in gCtrl.columnList | filter : {available:true } || {id:groupfield.fieldName}">
</select></div>
Upvotes: 0
Views: 1036
Reputation: 6372
You can pass the filter a custom function. You cannot pass arguments to the actual filter function, so the trick is to create a function that returns the filter function, and pass groupfield
to that.
function MyController() {
this.customFilter = customFilter;
function customFilter(groupfield) {
return function(value, index, array) {
return value.available || groupfield.fieldName === value.id;
}
}
}
<div ng-repeat="groupfield in gCtrl.groupingFields">
<select required class="form-control" ng-model="groupfield.fieldName" ng-options="c.id as c.title for c in gCtrl.columnList | filter : groupCtrl.customFilter(groupfield)"></select>
</div>
Upvotes: 1