【问题标题】:Select an option in select box which has a filter Angularjs在选择框中选择一个具有过滤器 Angularjs 的选项
【发布时间】:2016-02-20 14:53:10
【问题描述】:

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

下面是 HTML sn-p:

<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];

高度赞赏任何帮助。谢谢

【问题讨论】:

  • 分享带有问题的 jsFiddle 链接总是有帮助的

标签: javascript jquery angularjs angularjs-filter


【解决方案1】:

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

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-10-31
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-08-21
    • 2021-08-30
    • 2015-10-26
    • 2019-02-17
    相关资源
    最近更新 更多