angular.js - How to know which button is called in the controller in angular?
过去多啦不再A梦
过去多啦不再A梦 2017-05-15 16:49:50
0
2
545

This is how it is currently written

<li ng-repeat="data in datas"><a ng-click="handle($index)"></a></li>

I want to know how to write directly in the controller instead of passing parameters in HTML?

过去多啦不再A梦
过去多啦不再A梦

reply all(2)
淡淡烟草味
<button ng-click="onClick($event)">Button</button>

$scope.onClick = function(evt) {
  var index = $(evt.target).index();    //jquery
}
小葫芦

Although I don’t understand what the questioner wants to ask, I usually write like this in this situation:

<li ng-repeat="data in datas"><a ng-click="handle(data,$index)"></a></li>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template