Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ng-options filter by value in another dropdown

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

like image 392
Annie C Avatar asked Dec 02 '25 08:12

Annie C


1 Answers

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

like image 146
PSL Avatar answered Dec 03 '25 23:12

PSL



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!