ng-options 在另一个下拉列表中按值过滤一个数据
ng-options filter by value in another dropdown one data
我已经阅读了 中的一些示例。
但在我的例子中,数据在一个范围内。
我试过了
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/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>
我已经阅读了
但在我的例子中,数据在一个范围内。
我试过了
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/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>