H
H
he he2016-05-21 18:42:15
Angular
he he, 2016-05-21 18:42:15

How to detect a click on an element and read the name. json?

I make a request for a file in json format and display data on the page:
(a piece of markup)

<tr ng-repeat="test in myData">
      	<td>{{test.Name}}</td>
      	<td>{{test.City}}</td>
      	<td>{{test.Country}}</td>

I need to track a click on an element (in the future, there will be a markup with divs, and each div will have an ID) and read the name of the element that was clicked on.
I tried adding an id with a name to the td (for each element), but I don’t know how to track and read further.
Who can advise?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
T
titronfan, 2016-05-21
@tosha_lol_daaa

I don't know for sure if the answer is in the topic - but try this:

<tr ng-repeat="test in myData">
      	<td><div ng-click="yourFunc()">{{test.Name}}</div></td>
      	<td>{{test.City}}</td>
      	<td>{{test.Country}}</td>

yourFunc is the function that will take the clicks into account.
You can pass the desired id to this function, which will be taken into account.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question