How to set preselected value in ng-option?
问题 I have id from the city that is supposed to be selected in dropdown list, but I can`t manage to preselect it. Should I select it from directive or is there any other way? <select ng-model="cityId" ng-options="city.name for city in cities"></select> 回答1: Edit your ng-options to this: city.id as city.name for city in cities if you fetch the cities and don't know the ID's you could say in your javascript success function (which returns the cities): $scope.cityId = the_cities[0].ID to set the