请看这个plunker:https://plnkr.co/edit/U2oDUPl8w7lSlY8MkVLb?p=preview
为什么过滤器不能使用在表达式中具有track by的ng-options,并且在使用select as?
时工作<span> state selector : </span>
<select ng-model="filter.stateID"
ng-options="item.stateID as item.state for item in st_option"></select>
<br>
<span>county selector: select as</span>
<select
ng-model="filter.countyID"
ng-options="item.countyID as item.county for item in co_option | filter:{ co_state_id : filter.stateID }">
</select>
<br>
<span>county selector: track by</span>
<select
ng-model="filter.countyID2"
ng-options="item.county for item in co_option track by item.countyID | filter:{ co_state_id : filter.stateID }">
</select>
答案 0 :(得分:2)
更改
ng-options="item.county for item in co_option track by item.countyID | filter:{ co_state_id : filter.stateID }">
到
ng-options="item.county for item in co_option | filter:{ co_state_id : filter.stateID } track by item.countyID">
答案 1 :(得分:2)
更改为:
<span>county selector: track by</span>
<select ng-model="filter.countyID2"
ng-options="item.county for item in co_option | filter:{ co_state_id : filter.stateID } track by item.countyID">
</select>