Reputation: 7083
I have control Owners json object so i am trying to get worker from it , How can i assign worker json object to $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",
}
}],
Upvotes: 0
Views: 318
Reputation: 149
Try to use like this
$scope.controlOwners[0].worker.fullName = 'Rajasekaran, Shanmuga';
Upvotes: 0
Reputation: 104775
Specify the array index you want:
$scope.controlOwnerObj.worker = $scope.controlOwners[0].worker;
Upvotes: 3