0

I think the problem is that angular creates these elements with javascript, so after the jQuery domready. So jQuery doesn't see those elements into the DOM. What can i do?

HTML

<li ng-prepeat="el in els">{{el.attr}}</li>

JS

$("li").click(function(){ do something });
Donovant
  • 3,091
  • 8
  • 40
  • 68
  • try `$("li").on('click',function(){ do something });`? – Popo Feb 27 '14 at 01:43
  • Sorry, I was wrong, cause the event wasn't inside the domready scope. – Donovant Feb 27 '14 at 01:46
  • Why the heck are you doing that anyway? Use ng-click. JQuery is for angular noobs. – Zack Argyle Feb 27 '14 at 01:52
  • James has already answered how to do this the Angular way (using `ng-click`). Most stuff you want to do can be done in Angular JS without the need for jQuery. If you find yourself in a situation where you need to use jQuery, you're most likely doing something wrong. – kba Feb 27 '14 at 02:09

1 Answers1

1

You can use ng-click to achieve the clicking of li

<li ng-repeat="el in els" ng-click="doSomething()">{{el.attr}}</li>
jamesy829
  • 428
  • 4
  • 7