0

I want to bind Angularjs data inside onClick function, I have tried, but it's not working.

In below example I want to bind index value inside onclick function. What's wrong with my code. Can anyone point out this..

/**Example:**/
<input type="text" ng-repeat="items in itemList" onClick=tab("{{$index}}") 

1 Answer 1

3

I've done ...

ng-click="tab($index)"

This takes advantage of the fact that angular has it's own click; this allows for simpler variable declaration and passing.

Sign up to request clarification or add additional context in comments.

5 Comments

actually i want to bind inside onClick="tab('$index')", not using ng-click().because it's asking for tab change.so i need unique data for call tab bro..
I'm going to have to say that I don't understand the need to to onClick versus ng-click. The tab change will occur either way; in fact, I've successfully done this for a tabbed format within the last 60 days with ng-click. The two click events function essentially the same; just a matter of which framework tracks and fires the event. I'll keep a watch on this question; now I'm curious ... maybe if it's explained in more detail why you need the variance you'll get your answer.
Also, I don't think your question properly indicates why you need one over the other; you might want to adjust it.
Don't just use my code because I said so; if you have a valid reason, it might be something I need to learn ...
<input type="text" ng-repeat="items in itemList" ng-click=tab($index).

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.