0
我有一個窗體,在模態對話框中重複多行。每行有兩個<ui-select>
下拉菜單。基於兄弟UI選擇值過濾UI選擇下拉列表
第一個下拉列表中包含特定類型的選項,第二個下拉列表包含第一個下拉列表中類型的子類型。根據在第一個下拉列表中選擇的內容,我想過濾第二個數值,以僅顯示那些在第一個下拉列表中具有ParentId
等於所選類型的Id
的人。
這是我的標記
<tr ng-repeat="item in vm.responseItems">
<td>
<div class="form-group" show-errors>
<ui-select name="ResponseType" ng-model="item.Type" required>
<ui-select-match>{{$select.selected.Name | ngoLocalize}}</ui-select-match>
<ui-select-choices repeat="type in responseTypes | orderBy:'Name' | filter: $select.search">
<span ng-bind-html="type.Name | ngoLocalize | highlight: $select.search"></span>
</ui-select-choices>
</ui-select>
</div>
</td>
<td>
<div class="form-group" show-errors ng-if="responseInfoSubtypes.length">
<ui-select name="RseponseSubtype" ng-model="item.ResponseSubtype">
<ui-select-match>{{$select.selected.Name | ngoLocalize}}</ui-select-match>
<ui-select-choices repeat="type in (responseSubtypes | orderBy:'Name' | filter: $select.search | filter: subTypeFilter)">
<span ng-bind-html="type.Name | ngoLocalize | highlight: $select.search"></span>
</ui-select-choices>
</ui-select>
</div>
</td>
</tr>
我想要寫一個簡單的過濾器,看起來像下面,但我不知道我怎樣才能從過濾器內訪問第一個下拉的價值。
$scope.subTypeFilter = function (subType) {
return subType.ParentId === ???.Id;
}
我試圖扭轉它,併發送第一個下拉列表值作爲參數傳遞給過濾器,然後像下面的比較,但是它不工作,我打算將它的方式。
//'responseType' is the value from the first dropdown
//'index' is the current index of the subTypes being filtered
//'val' is the array of the subTypes being filtered
$scope.subTypeFilter = function (responseInfoType, index, val) {
return val[index].ParentId !== responseInfoType.Id;
}
這在理論上看起來是一件很簡單的事情,但我無法將頭圍住它。這怎麼能實現?