How to retrieve the clicked ElementId in angularjs?

前端 未结 2 1631
逝去的感伤
逝去的感伤 2020-12-14 07:59

I have the following line:


and in my controller I have:

$scope         


        
相关标签:
2条回答
  • 2020-12-14 08:44
    <button data-id="101" ng-click="showDetail($event)">click Me</button>
    
    $scope.showDetail = function(event)
    {
      console.log($(event.target).attr("data-id"));
    }
    
    0 讨论(0)
  • 2020-12-14 08:57

    I solved this:

    <a href="#" id="12345" data-ng-click="ShowId($event)">   
    
    $scope.ShowId = function(event)
    {
       alert(event.target.id);
    };
    
    0 讨论(0)
提交回复
热议问题