Angularjs

How To Access Element That Triggered Event In AngularJS 1.x

Posted by Weston Ganger on November 15, 2016

If your using angular and you want to access the DOM element that triggered the event but do not want to query the DOM to do so, then you can access it from your method like so.


<button type="button" ng-click="doWork($event)">Click This</button>

.controller("MyCtrl", function($scope){
  $scope.doWork = function($event){
    var element = angular.element($event.target);
  };
})


Related External Links:


Posted in Angular and Tagged with angularjs 


Need help on your next project or application?

I specialize in Ruby-on-Rails, AngularJS, Javascript, Bootstrap, and Hybrid Mobile Apps with Cordova & Ionic.

Contact Me

Recommended Posts