简体   繁体   English

使用ng-repeat时Javascript不起作用

[英]Javascript is not working when ng-repeat is used

I am new to AngularJs and working on a website. 我是AngularJs新手,并且正在一个网站上工作。 I am retrieving the data from Rest services in a page,I am able to display the data using ng-repeat . 我正在页面中从Rest服务检索数据,我可以使用ng-repeat显示数据。 But the problem is I have a normal javascript functioning element in the page. 但是问题是我在页面中有一个普通的javascript功能元素。 It is not working when i include the angularjs(ng-repeat) . 当我包含angularjs(ng-repeat)时,它不起作用。 Suggest me to work on it. 建议我继续努力。

Well nowhere up above do we see anything about ng-repeat, however I can tell you its probably got to do with the fact that you're binding your click event on dom ready, and then angular is changing your elements which nullifies the click listener. 嗯,在上面没有发现关于ng-repeat的任何信息,但是我可以告诉您,这可能与以下事实有关:您在dom ready上绑定了click事件,然后angular改变了您的元素,从而使click listener无效。 If you're using ng-repeat, you should be using ng-click as the handler for those events within your controller. 如果使用的是ng-repeat,则应将ng-click用作控制器中这些事件的处理程序。 Angular takes care of binding the handler specified using ng-click at the proper time when the element exists in the dom. 当元素存在于dom中时,Angular会在适当的时间绑定使用ng-click指定的处理程序。 jQuery really has no place in this if you are trying to use angular. 如果您尝试使用angular,jQuery确实没有任何位置。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM