javascript - Clicking on the element (say one or many image tag(s)) and a same function should be called in angularjs -
considering knowledge in jquery
$("img").click(function(){ // functionality }); so in above scenario, on click of img tag, functionality works.i need not write onclick each , every img tag in case.what equivalent in angularjs?
(ng-click of angularjs similar onclick of javascript)
you can override img directive
app.directive('img', function() { return { restrict: 'e', priority: 10000, compile: function(element, attrs) { var clickedme = function() { alert("clicked"); } element.bind('click', clickedme); } } });
Comments
Post a Comment