问题
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>
here is the plunker
http://plnkr.co/edit/bHb9AScd2m58acUUyI0t?p=preview
回答1:
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">
Plnkr
来源:https://stackoverflow.com/questions/28357097/ng-options-filter-by-value-in-another-dropdown