1

Let see my Angularjs code:

My function 'getequipselected' from my 'EmpApi' factory request data of my webservice and save it in response:

EmpApi.getequipselected(idequip).success(function (response) {
            $scope.editequipamento = response;

            console.log(response);

Its perfectly working, it printed on console log browser: Array [ Object ]

If a click on 'Objetc', I can see all parameters: idEquipamento, TAG, idDiretoria, idFabricante ...

So i trieded to print the $scope:

console.log($scope.editequipamento);

I printed it to check, it was the same of console.log(response)

The problem is here: I tried to print it:

console.log($scope.editequipamento.TAG);

I tried to print one parameter from object but in gave me 'undefined'

I trieded it because I'd like to pass this value to my html input, using ng-model="editequipamento.TAG", but the input is also undefined.

2 Answers 2

1

the response was array not an object so u have to access the first object of that array.

console.log($scope.editequipamento[0].TAG);
Sign up to request clarification or add additional context in comments.

Comments

0

Try editequipamento[0].TAG. I think your object is inside of array of list.

You need to use ng-repeat, if you have bulk array

4 Comments

Yes, but if you need pass multiple array object, then you need use ng-repeat for bind the record as table format
Perfect! It worked! Só, if a like to pass it to my html input can I do this: $scope.editequipamento[0] = $scope.equip So, use console.log(equip.TAG) ?
I just have one object in this array, how can I create a object in order to a array for this response?
please ask a new question fro more details

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.