我填充了一个动态下拉列表,如下所示:
$scope.idSelectionModel = [];
$http({
'url': '/getIds',
'method': 'POST',
'headers': {
'Content-Type': 'application/json'
}
})
.then(
function(
response) {
$scope.idResponse = response.data;
angular.forEach($scope.idResponse, function(value, key) {
$scope.idSelectionModel.push({
id: value
});
});
});
$scope.identity = $scope.idSelectionModel[0];
console.log($scope.idSelectionModel);
$scope.idResponse
返回一个列表,我对它做了一些修改,将不同的id映射到list元素。但我注意到有三种行为:
-
-
这个
console.log
-
当我尝试打印时
$scope.identity.id
,我得到一个异常“无法读取dropdown中未定义的属性'id'”。
有人能指导我吗?