0

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",
    }
}],

2 Answers 2

3

Specify the array index you want:

$scope.controlOwnerObj.worker = $scope.controlOwners[0].worker;
Sign up to request clarification or add additional context in comments.

3 Comments

how about if i want to display list of workers then index will not work in that case correct ?
Then you iterate over the array, angular.forEach() or Array#forEach
i am new to angularJS i added angular.forEach code can you see if it is correct i am still not getting the workers list
0

Try to use like this

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.