I'm hoping to solve three problems...
In my app page I have one select for states and another for counties. For states I have:
<select ng-model="filter.stateID" ng-options="item.stateID as item.state for item in st_option">
</select>
Data:
[
{ state="California", stateID="5"},
{ state="Arizona", stateID="3"},
{ state="Oregon", stateID="38"},
{ state="Texas", stateID="44"},
{ state="Utah", stateID="45"},
{ state="Nevada", stateID="29"}
]
For my County select I have:
<select ng-model="filter.countyID" ng-options="item.countyID as item.county for item in co_option">
</select>
Data:
[
{ county="Orange", countyID="191", co_state_id="5"},
{ county="Multiple Counties", countyID="3178", co_state_id="3"},
{ county="Sonoma", countyID="218", co_state_id="38"},
{ county="Los Angeles", countyID="190", co_state_id="44"}
]
This is my ng-repeat
:
<div ng-repeat="project in projects | filter:filter">
<div>
State: {{project.state}}<br>
County: {{project.county}}<br>
<span ng-hide="{{project.stateID}}"></span>
<span ng-hide="{{project.countyID}}"></span>
</div>
</div>
So, as you can see I'm using the stateID
on the state select and on the county select I have the corresponding state id set in co_state_id
in the county data set.
I'd like to do a few things:
- Hide the county select until a state is selected.
- After a state is selected, filter the county select options by the selected
stateID
/co_state_id
- Filter the
ng-repeat
by first thestateID
, then by thecountyID
.
I also haven't see a way to set filter.stateID
to true
or filter by a number instead of a string. when I filter by stateID I get mixed results because some stateID
's can have "1" in them..