如何访问对象数组中的对象?

时间:2016-03-18 19:18:30

标签: javascript angularjs

我控制了Owners json对象,所以我试图从中获取worker,如何将worker json对象分配给mmmm >>> January yyyy >>> 2016 dd >>> 02 d >>> 2 dddd >>> Monday mmm >>> Jan mm >>> 01 m >>> 1

ctrl.js

$scope.controlOwnerObj.worker

json.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);
        }

2 个答案:

答案 0 :(得分:3)

指定所需的数组索引:

$scope.controlOwnerObj.worker = $scope.controlOwners[0].worker;

答案 1 :(得分:0)

尝试像这样使用

$scope.controlOwners[0].worker.fullName = 'Rajasekaran, Shanmuga';