Search code examples
angularjsng-optionsangularjs-select

Filter selection based on first selection


<select ng-model="chosenCategory" >
<option ng-repeat="category in categories">{{category}}</option>     
</select>

<select id="selectedFeed" name="selectedFeed" ng-model="selectedFeed" ng-init="selectedFeed=feed.url" ng-change="loadFeed(selectedFeed, $event)" ng-options="feed as feed.name for feed in userfeeds | filter: feed.category = chosenCategory">
</select>  

I have been trying for a day now to get this filter to work i don't know what's wrong.. i've tried many variations of code. This code was working then all of a sudden it stopped. Please help! I am trying to filter the second option if the feed category matches the chosen category in the first option


Solution

  • Ok I solved my question by using ng-options on the first select as well.. dont know why this was preventing the filter from working

    <select ng-model="chosenCategory" ng-options="category as category for category in categories" >
    </select>