我正在尝试根据数据库值在第二个选择框中选择一个特定选项。第二个选择框中应用了一个筛选器。这将根据第一个选择框中选择的选项进行过滤
下面是 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];
任何帮助都非常感谢。谢谢
发现问题。问题出在数据上。两个或多个投诉类别可以存在相同的投诉类型。但是我在设置选择框时仅根据投诉类型进行过滤。在过滤器中添加投诉类别解决了问题。请在下面找到更改。
$scope.t_selectedcomptype = $filter('filter')($scope.complainttypemappinglist, { ComplaintTypeName: $scope.ticketdetailforid.ComplaintType, ComplaintCategoryName: $scope.ticketdetailforid.ComplaintCategory })[0];