0

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>
Enes Giray
  • 326
  • 2
  • 9

2 Answers2

2

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)
}
codsforco
  • 56
  • 1
  • 5
0

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

Community
  • 1
  • 1
Deepak Sharma
  • 458
  • 9
  • 21