In AngularJS when you are using ng-options, you can filter out the options by calling a custom function you have in the controller.
Let’s say you have following set of employees and when you display all these employees inside HTML select using ng-options, you can see all the employees in a dropdown.
And now let's say, you only need employees whose department is “VS”.
For that I am filtering the employees where department equals “VS” and that’s by calling a custom function. (here for this simple requirement I really don’t need to write a custom filter function, I can supply the filter even inline, but for the demonstration purposes, let’s call a custom function.)
So here is the filter function inside the controller.
And this is my filtered employees.
|Result with Filter|
Even I can pass parameters to filterEmployeesByDepartment function.
And if I change the function accordingly,
Here, param will have the value “Hello World”.