以下是正常运行的代码,我面临的唯一问题是第一次(直到未选中)的第二个选项值变为空白。让我知道我在这里做错了什么。
代码 -
YearMonth: int
Level4Name: varchar(50)
L4ManagerID: varchar(8)
脚本 -
<div>
<h3>Select a country</h3>
<select id="select-02"
class="slds-select"
name="country"
ng-model="myForm.companyaddress.country"
ng-options="conList.name for conList in countryList track by conList.id"
ng-init="myForm.companyaddress.country = countryList[0]"
ng-change="stateList = myForm.companyaddress.country.states"
style="height: 37px;">
</select>
</div>
<div>
<h3>Select a state</h3>
<select
id="select-03"
class="slds-select"
style="height: 44px;"
ng-init="myForm.companyaddress.state = countryList[0].states[0]"
ng-options="sList.name for sList in stateList track by sList.stateid"
ng-model="myForm.companyaddress.state">
</select>
</div>
工作Plnkr - http://plnkr.co/edit/ZYmMJG8CbxrpdOjuUh9k?p=preview
答案 0 :(得分:1)
到目前为止我看到的问题是,一旦你选择了一个国家,myForm.companyaddress.state选项就不在选项列表中,所以它是空白的
您可以更改此
的首次ng-changeng-change="stateList = myForm.companyaddress.country.states; myForm.companyaddress.state = stateList[0]"
检查此plnkr