ng-options filter by value in another dropdown

只谈情不闲聊 提交于 2019-12-31 02:18:10

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!