【发布时间】:2017-06-16 13:11:55
【问题描述】:
我正在使用 AngularJS。我正在尝试将下拉列表与响应中显示的值绑定。但我无法设置所选数据。它始终显示默认值。下面是index.cshtml:
<div class="col-sm-4">
<select name="CopyseasonTypeSelect" ng-model="CopyselectedSeasonType" ng-options="CopySeason.SeasonTypeName for CopySeason in seasons">
<option value="">-- Select the Season --</option>
</select>
</div>
在controller.js中
testAPIService.getSeasonById(nId).success(function(response) {
$scope.seasonByIdReponse = response;
$scope.CopyselectedSeasonType = response.SeasonType; // I am getting "Summer"
$scope.init();
});
}
下拉列表的值是“-- 选择季节--”、“冬季”、“夏季”、“春季”
对象数组如下:
[object Object],[object Object],[object Object],[object Object]
[
0: {
[functions]: ,
$$hashKey: "object:78",
__proto__: { },
Id: 1,
ImageUrl: "testicon.png",
SeasonDetail: null,
SeasonTypeName: "Winter"
},
1: { },
2: { },
3: { },
length: 4
]
如何在服务的下拉菜单中设置值?
【问题讨论】:
-
四季数组结构是什么?
标签: angularjs