別のドロップダウンリスト(DDL)を別のドロップダウンリストでフィルタリングしようとしています。私はそれを行う方法については、この質問を参照しました:Angularjs Filter data with dropdownドロップダウンリストフィルタが機能しません
私のDDLは次のようになります。
<select class="form-control input-sm"
ng-change="echo(selectedDepartment);"
ng-model="selectedDepartment"
ng-options="d as d.DepartmentName for d in departmentList track by d.DepartmentId"></select>
<select class="form-control input-sm"
ng-change="echo(selectedTeam);"
ng-model="selectedTeam"
ng-options="t as t.TeamName for t in (teamList | filter: filterTeams) track by t.TeamId"></select>
<select class="form-control input-sm"
ng-change="echo(selectedRep);"
ng-model="selectedRep"
ng-options="r as (r.FirstName + ' ' + r.LastName) for r in (repList | filter: filterReps) track by r.UserId"></select>
ng-change
でecho
関数はちょうどその時私は、モデルが更新されていることを確認することができますconsole.log
を使用しています選択されています。ここで
は私のフィルター機能です:
$scope.filterTeams = function (team) {
console.log("Team's DeptId: " + team.Department.DepartmentId + " Selected Dept Id: " + $scope.selectedDepartment.DepartmentId);
return (team.Department.DepartmentId === $scope.selectedDepartment.DepartmentId);
};
$scope.filterReps = function(rep) {
return (rep.TeamId === $scope.selectedTeam.TeamId);
};
奇妙だ私は私のフィルタ機能で$scope.selectedDepartment
を参照するとき、それはng-change
で実行されているエコー機能は、それが更新されています示した後でも、常に空のオブジェクトであるということです。
フィルタ関数は、DDLが参照する同じコントローラの一部であり、同じ$scope
オブジェクトを持ちます。
チームを選択すると、team.Department.DepartmentId
と定義されていないDDLが空白になります。
$scope.selectedDepartment
は空のオブジェクトで、同時に入力できますか?