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 the stateID, then by the countyID.
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..
解决方案
Usually you only want to ask one question per post but i'll give these three a shot.
Part 1: Add an ng-show for filter.stateID. Since you can't deselect a state, you can use a one time binding if your angular is ^1.3.
<select ng-show="::filter.stateID" ng-model="filter.countyID" ng-options="item.countyID as item.county for item in co_option">
Part 2: Add filter for {co_state_id : filter.stateID}
<select ng-show="::filter.stateID != null" ng-model="filter.countyID" ng-options="item.countyID as item.county for item in co_option | filter:{ co_state_id : filter.stateID }">
Part 3:
You are using the pattern object for the filter, shouldn't matter if the value of the id is 1:
Object: A pattern object can be used to filter specific properties on objects contained by array. For example {name:"M", phone:"1"} predicate will return an array of items which have property name containing "M" and property phone containing "1". A special property name $ can be used (as in {$:"text"}) to accept a match against any property of the object or its nested object properties. That's equivalent to the simple substring match with a string as described above. The predicate can be negated by prefixing the string with !. For example {name: "!M"} predicate will return an array of items which have property name not containing "M".