Angularjs ng选项中的默认选定选项
需要选择“Pune”作为默认选项Angularjs ng选项中的默认选定选项,angularjs,selected,ng-options,Angularjs,Selected,Ng Options,需要选择“Pune”作为默认选项 <div ng-app="storeLocater" ng-controller="selectOptions"> <select ng-model="cities" ng-options="store for (store,city) in stores"> </select> </div> 这是同样的。我需要帮助了解如何在当前数据结构中为所选选项添加属性 <div ng-app="store
<div ng-app="storeLocater" ng-controller="selectOptions">
<select ng-model="cities" ng-options="store for (store,city) in stores">
</select>
</div>
这是同样的。我需要帮助了解如何在当前数据结构中为所选选项添加属性
<div ng-app="storeLocater" ng-controller="selectOptions">
<select ng-model="cities" ng-options="store for (store,city) in stores">
</select>
</div>
您需要在ng模型中设置默认值,在您的情况下是:
城市
尝试以下操作:
<select ng-model="stores.Pune" ng-options="store for (store,city) in stores">
</select>
答案是,我认为您应该首先更改数据结构。谢谢@newdev