Javascript Ng选择选项值
我正在尝试创建一个ng select来选择您的国家并通过相关的国家代码。我有一个散列,但我不确定它是否正确Javascript Ng选择选项值,javascript,angularjs,Javascript,Angularjs,我正在尝试创建一个ng select来选择您的国家并通过相关的国家代码。我有一个散列,但我不确定它是否正确 <select ng-model="myCountry" ng-options="country.name group by country.iso for country in countries" placeholder="Country"> </select> 如何让“iso”作为带有“name”的值传递,而且我似乎无法在国家/地区的占位符处将其
<select ng-model="myCountry" ng-options="country.name group by country.iso for country in countries" placeholder="Country">
</select>
如何让“iso”作为带有“name”的值传递,而且我似乎无法在国家/地区的占位符处将其设置为默认值
如果我不够清楚,请告诉我试试这个
<select ng-model="myCountry" ng-options="country.iso as country.name group by country.iso for country in countries" placeholder="Country">
<option value="">Country</option>
</select>
国家
我想您可能希望表达式使用以下语法:
<select ng-model="myCountry" ng-options="country.iso as country.name for country in countries" placeholder="Country">
<option style="display:none" value="">Country</option>
</select>
国家
考虑到您的
分组依据
似乎每个项目都是唯一的,我猜您不会真的希望将其作为选择
分组之前我错过了占位符要求。。。我已经更新了我的答案
<select ng-model="myCountry" ng-options="country.iso as country.name for country in countries" placeholder="Country">
<option style="display:none" value="">Country</option>
</select>