gpt4 book ai didi

javascript - ng-options 按另一个下拉列表中的值过滤数据

转载 作者:行者123 更新时间:2023-12-03 10:05:24 24 4
gpt4 key购买 nike

我读过 ng-options filter by value in another dropdown 中的一些例子.

但就我而言,数据位于一个范围内。

我已经尝试过

Make:
<select ng-model="makeng" ng-options="option.id as option.display for option in makes">
<option ng-disabled="true" ng-selected="true" value="">Select a make</option>
</select>


Model:
<select ng-model="modelng" ng-options="option.data.name for option in makes | filter:{id:makeng}">
<option ng-disabled="true" ng-selected="true" value="">Select a model</option>
</select>

地址:http://plnkr.co/edit/MlbBcVso57H3tyVEJa8o?p=preview

最佳答案

根本不需要过滤器:

http://plnkr.co/edit/OjM1yJPYV1vQh5HRDNQ1?p=preview

品牌:

<select ng-model="makeng" ng-options="option as option.display for option in makes">
<option ng-disabled="true" ng-selected="true" value="">Select a make</option>
</select>

型号:

<select ng-model="modelng" ng-options="option.name for option in makes[makes.indexOf(makeng)].data">
<option ng-disabled="true" ng-selected="true" value="">Select a model</option>
</select>

关于javascript - ng-options 按另一个下拉列表中的值过滤数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30384231/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com