Frank7390035
Posts: 0
Joined: Thu Feb 19, 2015 1:37 am

how to reference an element in ionic app from an ng-click event

Hello,

Apologies for the naive question: I have a list of items and I would like to change the class of a particular list-item when the user taps on this item using some js via ng-click

I thought I could reference the selected element using the keyword "this" e.g.

this.removeClass("myclass").

This doesn't work..what should I do instead?

Thanks,
Frank

Serhii Kulibaba
Posts: 150
Joined: Tue Aug 27, 2013 1:47 pm

how to reference an element in ionic app from an ng-click event

Hello Frank,

You can't reference an element in the function ng-click. Please add the class to that component using the scope variable and directive ng-class: https://docs.angularjs.org/api/ng/dir...

  1. Set the value of the scope variable in the function ng-click
  2. Use that variable in the directive ng-click

Return to “Issues”