I've looked at the documentation on the Angular site here but I'm still a little bit confused.
I have an angular directive who's template contains elements created by ng-repeat
. Each of these elements has a common class. I'm trying to select those elements by class so that I can pass a handler when an event is triggered on an element belonging to that class.
As far as I can tell from the answer here I have the option of selecting those elements with jqLite
or angular.element()
. My jQuery is included AFTER Angular is included. I assume that this should be done this way because I want to select elements of a specific class AFTER Angular has produced them through my directive.
I'm not actually trying to use the .click()
event on the class, it's just a proof of concept. I have the following code in the controller associated with the containing element of the directive:
$(".gallery-image").click(function(){
alert("test");
});
What I'm attempting to do should be fairly apparent, I'm just unsure how to deal with this cocktail of Angular and jQuery.
How would I select and run an event handler with jQuery on these elements?