How to get value of an element on Angular.js


#1

am trying to figure out what is the correct way to get the value of an element in Angular.js.

I am inserting a JSON called options and printing out the values into label tags. The searchStep2 function is supposed to alert the text in the label once a user clicks on it.

My exact code is

<li ng-repeat="option in options" >
  <label ng-click="searchStep2()" class="option">{{option}}</label>
</li>

In Jquery, I would simply use .text() function to get the value. So my question is what is the equivalent to .text() in Angular.js.

Thanks…


#2

If you want to use that value in your searchStep2() function, just pass it as a parameter in the click event: searchStep2(option)