I am trying to make a multiple selection list with a dropdown above it as a filter. The value of the dropdown above contains the department name that will then display its employees in the list below according to the selected department above.
Here is my scope:
var self = this;
self.users = [{ department: "A", name: "santos" }, { department: "B", name: "suarez" }, { department: "C", name: "domingo" }, { department: "A", name: "james" }, { department: "B", name: "black" }, { department: "C", name: "de leon" }, { department: "A", name: "dela cruz" }, { department: "B", name: "robertson" }, { department: "C", name: "williams" }, { department: "A", name: "crawford" },
{ department: "B", name: "garcia" }, { department: "C", name: "navarro" }, { department: "A", name: "lim" }, { department: "B", name: "lee" }, { department: "C", name: "vasquez" }, { department: "A", name: "montano" }, { department: "B", name: "trump" }, { department: "C", name: "arroyo" }, { department: "A", name: "aquino" }, { department: "B", name: "duterte" }];
and here is my html:
<select class="form-control" ng-options="item as item.department for item in formsDcfCtrl.users" ng-model="departmentsList">
<option value="" selected>Departments</option>
</select>
<select multiple class="form-control" ng-options="x as x.name for x in formsDcfCtrl.users | filter:departmentsList" ng-model="usersList"></select>
but I get different results:
the value of the list below is fine but the values of the dropdownlist is based from each of the values of the departments in the array:
and when I select a letter(department) from the dropdown, instead of ALL the names that are in department A, for example, will be showed in the list below, only the name whose specific value of department in that specific element in the selected dropdown value is displayed. How do I solve this?
