Suppose there is a scheme in SVG format, on which there are a lot of different elements, for each element you need to add a click event, how to ( efficiently ) add an event to hundreds of elements. Is it justified to use such a directive, or is it easier by means of jQuery
var app = angular.module('pl', []); app.controller('MainCtrl', function($scope) { }); app.directive('rect', function() { return function(scope, element, attrs) { element.bind("click", function(event) { console.log("clicks"); }); }; }) <body ng-controller="MainCtrl"> <svg id="svgg" width="600px" height="600px"> <rect x="0" y="0" width="10px" height="10px"/><rect x="0" y="10" width="10px" height="10px"/><rect x="0" y="20" width="10px" height="10px"/><rect x="0" y="30" width="10px" height="10px"/> ... </svg> </body> </html>