Sometimes we need to access the attributes of event invoking DOM element. AngularJS proving $event directive to track events. we can find event invoking elements by using $event.target

Program Flow

  1. Pass $event while calling function
  2. Get element by using $event.target
  3. Make different type element operations like here

Program

$scope.displayHtml = function($event) {
   var myEl = angular.element($event.target);
   alert(myEl.html());
}

0 comments:

Blogroll

Popular Posts