I've got two dropdowns. The allowable options in those dropdowns should be filtered based on what's in the other dropdown. Here's the first dropdown:
<select ng-model="filter.levelPregenerate">
<option value="">All</option>
<option value="assox">Associate's</option>
<option value="bachx">Bachelor's</option>
<option value="mastx">Master's</option>
<option value="doctx">Doctorate</option>
<option value="nondx">Non-Degree</option>
<option value="bridx">Bridge</option>
</select>
And the second dropdown is an ng-repeat, as follows:
<select ng-model="filter.degreeTypePregenerate">
<option value="">All</option>
<option ng-repeat="type in degreeType | orderBy:'toString()'">{{type}}</option>
</select>
And here's the array being repeated above:
$scope.degreeType = ['BA', 'BS', 'MA', 'MBA',
'MDIV', 'MED', 'MFA', 'MPH',
'MS',' DNP', 'EDD', 'PHD',
'EDSPL', 'GRDCERT'];
The options in the first and second dropdown should be filtered based on each other. Here's the mapping between the two (how the filter should work):
assox: '';
bachx: 'BA, BS';
mastx: 'MA, MBA, MDIV, MED, MFA, MPH, MS';
doctx: 'DNP, EDD, PHD';
nondx: 'EDSPL, GRDCERT';
bridx: ''
So, if 'BA' is selected in the second dropdown, 'bachx' should be the only option available in the first dropdown. Conversely, if 'doctx' is selected in the first dropdown, 'DNP', 'EDD', and 'PHD' should be the only select-able options in the second dropdown.
Here's a Codepen with the full code: http://codepen.io/trueScript/pen/LVZKEo
I don't think I can simply apply a basic '| filter:foo' to the second dropdown, because it wouldn't know how to filter it. What is the Angular way to do this?
[angularjs] dropdown filterin the search box at the top of this page? hopefully, some relevant question/answers turn up. for example this SO Post$scope.degreeTypeto make mapping easier? ...e.g. [{'assoc':'BA'}, {'assoc':'BS'},..etc] as anarray of objects