jQuery click events not working with AngularJS

前端 未结 3 1055
醉酒成梦
醉酒成梦 2020-12-21 17:50

I am in the process of converting my multipaged php + jquery website into a single page angular app. However I have written a lot of code with jquery already so only intend

3条回答
  •  抹茶落季
    2020-12-21 18:23

    The reason is because, when you bind the event to the element #myElement the element does not exist yet. Since that element is being rendered as a part of the directive template you would need to move the bind handler inside the directive link function. Well, you could technically use event delegation to solve the issue but it is just another hack upon hack. Best bet would be to use ng-click itself on the element (Which you already said you have tried out).

提交回复
热议问题