在选择框中选择一个具有过滤器Angularjs的选项

时间:2016-02-20 14:53:11

标签: javascript jquery angularjs angularjs-filter

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

以下是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)设置第二个选择框值?我尝试过以下代码,但它没有用。

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

任何帮助高度赞赏。感谢

1 个答案:

答案 0 :(得分:0)

发现问题。问题在于数据。两种或多种投诉类别可以存在相同的投诉类型。但是我在设置选择框时仅基于抱怨类型进行过滤。在过滤器中添加投诉类别解决了问题。请在下面找到更改。

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