0
我有這樣的代碼:取消對選擇無效的,空的和原始的類與動態選擇一個選項
HTML:
<div class="row">
<div class="col-md-6">
<md-input-container>
<label>Country</label>
<md-select required ng-model="model.userCountry" id="res_country" name="res_country" ng-change="updateTimeZone(model.userCountry)" aria-label="select">
<md-option ng-repeat="country in country" value="{{country.gid}}"> {{country.name}} </md-option>
</md-select>
</md-input-container>
</div>
<div class="col-md-6">
<md-input-container id="timezone">
<label>Timezone</label>
<md-select required ng-model="model.userZone" id="res_zone" name="res_zone" aria-label="select">
<md-option ng-repeat="zone in zone" value="{{zone.gid}}"> {{zone.name}} </md-option>
</md-select>
</md-input-container>
</div>
</div>
在我的控制器功能我走時區的名單基礎上,國家選定。當我選擇一個國家時,如果只有一個時區,它會被默認選中。
我的問題是,當我加載視圖與以前保存的國家和時區,時區選擇具有ng-empty和ng無效的類,如果我再次選擇相同的選項,它會被標記爲錯誤。另一種情況是,當我選擇一個擁有2個或更多時區的國家時,選擇其他國家只有1個。時區將被選中,但也會被標記爲錯誤。我怎樣才能刪除這些類?