Select select 框中的选项有过滤器 Angularjs

Select an option in select box which has a filter Angularjs

我正在尝试根据数据库值 select 第二个 select 框中的特定选项。第二个 select 框应用了过滤器。这将根据第一个 select 框

中的选项 select 进行过滤

下面是 HTML 片段:

<select id="select_comptype" class="ticketselectboxwidth select-style" ng-model="t_selectedcomptype" ng-options="comptype.ComplaintTypeName for comptype in complainttypemappinglist |  filter: {ComplaintCategoryName: t_selectedcomplaintcategory.ComplaintCategoryName}"></select>  

我如何根据来自数据库的值 ($scope.ticketdetailforid.ComplaintType) 设置第二个 select 框值?我试过下面的代码,但没有用。

 $scope.t_selectedcomptype = $filter('filter')($scope.complainttypemappinglist, { ComplaintTypeName: $scope.ticketdetailforid.ComplaintType })[0];

非常感谢任何帮助。谢谢

找到问题了。问题出在数据上。两个或多个投诉类别可以存在相同的投诉类型。但我在设置 select 框时仅根据投诉类型进行过滤。在过滤器中添加投诉类别解决了问题。请在下面找到更改。

$scope.t_selectedcomptype = $filter('filter')($scope.complainttypemappinglist, { ComplaintTypeName: $scope.ticketdetailforid.ComplaintType, ComplaintCategoryName: $scope.ticketdetailforid.ComplaintCategory })[0];