Angularjs HTML选择,以前选择的角度值

Angularjs HTML选择,以前选择的角度值,angularjs,Angularjs,我在HTML中有select选项,我不知道在重新加载后如何放置先前选择的值 <select ng-init="city_id = city_id" name="region" id="region" ng-model="city_id" > <option value="-1" selected="selected">Select area</option> <option ng-repeat="city in cities" valu

我在HTML中有select选项,我不知道在重新加载后如何放置先前选择的值

<select ng-init="city_id = city_id" name="region" id="region" ng-model="city_id" >
    <option value="-1"  selected="selected">Select area</option>
    <option ng-repeat="city in cities" value="{{city.id}}" ng-class="{ 'bold' : city.capital == 1 }">{{ city.name }}</option>
</select> 
我使用controller并创建了$scope.city\u id,它有一个值。但是select仍然具有默认值

Select area项对我来说是必需的,因为我无法修改json数据以在cotroller中添加此选项

解决方案:

<option ng-selected="city_id == city.id" ng-repeat="city in cities" ...

使用为选择选项选择的ng

如果问题是控制器已损坏,您可能希望将其存储在一个值中,即angular.module“myApp”。值“name”,值

查看