Javascript 如何访问对象数组中的对象?
我有控件所有者json对象,所以我试图从中获取worker,如何将worker json对象分配给Javascript 如何访问对象数组中的对象?,javascript,angularjs,Javascript,Angularjs,我有控件所有者json对象,所以我试图从中获取worker,如何将worker json对象分配给$scope.controlOwnerObj.worker ctrl.js if ($state.is('app.editControl')) { angular.forEach($scope.controlDTO.controlOwners,function(owner){ $scope.selectedOwners = owner
$scope.controlOwnerObj.worker
ctrl.js
if ($state.is('app.editControl')) {
angular.forEach($scope.controlDTO.controlOwners,function(owner){
$scope.selectedOwners = owner
})
// $scope.selectedOwners = $scope.controlDTO.controlOwners[0].worker;
// $scope.controlDTO.controlOwners[0].worker.fullName;
console.log('EDIT CONTROL OWNERS DATA', $scope.selectedOwners);
}
json.js
"controlOwners": [{
"worker": {
"workerKey": -1093,
"sourceFeed": null,
"statusLookUpCode": null,
"externalId": null,
"createdUserText": null,
"createdTimestamp": null,
"modifiedUserText": null,
"modifiedTimestamp": null,
"stdId": "ZK84T1N",
"ccId": null,
"empClasId": null,
"deptId": null,
"fullName": "Rajasekaran, Shanmuga",
}
}],
指定所需的数组索引:
$scope.controlOwnerObj.worker = $scope.controlOwners[0].worker;
指定所需的数组索引:
$scope.controlOwnerObj.worker = $scope.controlOwners[0].worker;
试着这样使用
$scope.controlOwners[0].worker.fullName = 'Rajasekaran, Shanmuga';
试着这样使用
$scope.controlOwners[0].worker.fullName = 'Rajasekaran, Shanmuga';
如果我想显示worker列表,那么索引在这种情况下将不起作用,对吗?然后遍历数组,
angular.forEach()
或数组#forEach
我是angularJS的新手,我添加了angular.forEach代码,你能看到它是否正确吗?我仍然没有得到工作列表。如果我想显示工作列表,那么索引在这种情况下将不起作用。正确吗?然后你迭代数组,angular.forEach()
或数组#forEach
我是angularJS的新手,我添加了angular.forEach代码你能看到它是否正确吗我仍然没有得到工人列表