I am trying to add a conditional filter to mine ng-options
. Parameters should be displayed only if the identifier from the parameter array is id from another selection input.
First one ng-options
:
<select ng-model="requestDepartment" ng-options="department.DepartmentID as department.DepartmentName for department in departments" class="form-control">
<option value="">Select</option>
</select>
The second ng-options
with filtering:
<select ng-model="requestCategory" ng-options="category.CategorytName for category in categories | filter:{category.ParentID : requestDepartment}" class="form-control">
<option value="">Select</option>
</select>
The second ng-options
should only show entries that match the ng model from the first ng-options
.
The data structure is as follows:
DepartmentID: 1
DepartmentName: "IT"
ParentID: 1
CategoryName: "Sharepoint"
So, if the "IT" section is selected, I want to display only those categories that correspond parentID
, in this case, "Sharepoint".
I tried filter:{category.ParentID : requestDepartment}
with no luck.
Any suggestions?
Update:
I added the fiddle: http://jsfiddle.net/q53ro5sr/4/