Join the Stack Overflow Community
Stack Overflow is a community of 6.6 million programmers, just like you, helping each other.
Join them; it only takes a minute:
Sign up

How get index of one of two div tag without i don't using ng-repeat?
I tried this but it didn't work;

<div ng-click="formselect($index)"></div>
<div ng-click="formselect($index)"></div>
share|improve this question
1  
Are you at least in the context of an ng-repeat? – Makoto 2 days ago
2  
That's not ng-submit. – JLRishe 2 days ago
    
@Makoto There are four div tag, i want to send index of clicked tag – Enes Giray 2 days ago
    
So like <div ng-click="formselect(0)"></div><div ng-click="formselect(1)"></div>...? – Phil 2 days ago
    
@Phil i doing as you say already, but i want to get index of tags like jquery – Enes Giray 2 days ago
up vote 2 down vote accepted

HTML:

<div ng-click="formselect($event)"></div>
<div ng-click="formselect($event)"></div>

JS:

var formselect = function(te) {
    return Array.prototype.slice.call(document.getElementsByClassName(te.target.className)).indexOf(te.target)
}
share|improve this answer

for me this worked

<div ng-click="formselect('0')"></div>
<div ng-click="formselect('1')"></div>

or if you want to load variables from angular js look into this fiddle or refer to the answer provided in the link

share|improve this answer
    
I using array now but what i want to learn is to get index of html tags as like on jQuery, with Angular – Enes Giray 2 days ago

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.