Here is the solution.. https://plnkr.co/edit/ilpcQl8ArW2o745AvGaW?p=preview
On Friday, July 8, 2016 at 8:58:15 PM UTC-4, Cool Zebra wrote:
>
> In jQuery this would be very easy for me.
>
>
> $("ul").on("click", function() {
> $(this).find("li").each(function() {
> alert($(this).attr("id"));
> });
> });
>
>
> However, I'm having difficulties implementing this in Angular. I know that
> it's a best practice to use a custom directive for this.
>
> https://plnkr.co/edit/18RwM2eNjRhfwbst7ub7?p=preview
>
> .directive("getChildren", function() {
> return {
> restrict: "A",
> link: function(scope, element, attrs) {
> element.bind("click", function() {
> this.children().forEach(function(child) {
> alert(child.attr("id"));
> });
> })
> }
> }
> })
>
> I'm not sure why this isn't working.
>
> Any help will be appreciated.
>
--
You received this message because you are subscribed to the Google Groups
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.