Answer the question
In order to leave comments, you need to log in
How to filter a table using checkboxes on nested object fields using AngulaeJS?
I need to filter a table with an array of objects by some parameters. And you need to do this with the help of checkboxes / radios, etc.
Here is an example of objects:
{
"_id": "24b87678e363397ec9e89d61bdde5d90",
"priority": 1,
"updated": "2015-04-27T15:30:36Z",
"name": "angelus",
"active": true,
"options": {
"disable_work": true,
"remote": yes
}
},
{
"_id": "24b87678e363397ec9e89dadbdde5d90",
"priority": 3,
"updated": "2015-04-27T15:30:36Z",
"name": "raminus",
"active": true,
}
$scope.itemFilterForm = {};
<input type="checkbox" ng-true-value="true" ng-false-value="" ng-model='itemFilterForm.options.disable_work'>
Answer the question
In order to leave comments, you need to log in
Referring to the angularjs documentation https://docs.angularjs.org/api/ng/filter/filter
we find that the filter filter can take three parameters
1. data array
2. expression - string, object or function (in your case, this is a form object)
3. comparison function - this is what we need to define in our scope
This function takes 2 parameters, the first is the list element, the second is the object of your form. This function returns true, false or undefined. You can define the logic for comparing these two parameters yourself, here is an example stackoverflow.com/questions/21199759/angularjs-fil...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question