ng-options 在另一个下拉列表中按值过滤 [英] ng-options filter by value in another dropdown
本文介绍了ng-options 在另一个下拉列表中按值过滤的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这似乎是一个非常直接的代码,但我不知道为什么它不起作用.
This seems to be a really straight forward code, but I cannot figure out why it is not working.
我想通过选定的制造"过滤模型"下拉菜单,
I want to filter the 'model' dropdown by selected 'make',
Make:
<select ng-model="makeng" ng-options="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.display for option in models | filter:{make:makeng}">
<option ng-disabled="true" ng-selected="true" value="">Select a model</option>
</select>
这里是plunker
http://plnkr.co/edit/bHb9AScd2m58acUUyI0t?p=preview
推荐答案
问题在于您的第一个 ngoption,您需要使用 select as<将模型设置为
value
属性的值/code> 语法 option.value as option.
.
Problem is with your first ngoption, you need to set the model as the value of value
property using select as
syntax option.value as option.
.
<select ng-model="makeng"
ng-options="option.value as option.display for option in makes">
这篇关于ng-options 在另一个下拉列表中按值过滤的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文