D
D
Dmitry Inozemtsev2016-02-11 18:30:56
Angular
Dmitry Inozemtsev, 2016-02-11 18:30:56

How to get value from array in Angular.JS?

Hello!
I apologize in advance for the incredibly noob question. There was a need for a small editing of a template written in Angular, and I am completely zero in it.
The template has this entry:

<tr ng-repeat="item in data.order.contacts">
     <td><b>{{item.label}}:</b></td>
     <td>{{item.value}}</td>
</tr>

The data.order.contacts object contains a JSON array with data.
The question is, how do I get the specific value of a specific parameter from this array?
Sorry one more time :)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
kealman, 2016-02-11
@kealman

itemis a reference to an array element, ng-repeat is analogous to forEach.
Accordingly, item contains all the fields of the data.order.contacts array element.
item.<field_name>and there is a specific value of a specific parameter.
If you are talking about a specific element of the array, then it data.order.contacts[element_index]will lead you to it :)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question