简体   繁体   English

AngularJS应用有时会用href和ng-href刷新

[英]AngularJS app occasionally refreshes with href & ng-href

Occasionally my AngularJS app refreshes when clicking a link that takes you somewhere within the site. 有时,我的AngularJS应用程序在单击将您带到站点内某个位置的链接时会刷新。 There doesn't appear to be any consistency with this, sometimes it's with href="/foo" and other times with ng-href="/foo/{{bar}}" 似乎没有任何一致性,有时是与href="/foo" ,有时与ng-href="/foo/{{bar}}"

I seem to be able to reproduce this when I click between links in the navigation a bit too quickly and I get a full app refresh. 当我单击导航中的链接之间的速度太快时,我似乎可以重现此信息,并且可以刷新整个应用程序。

I would really like to avoid replacing all my hrefs across the site with ng-click that triggers $location.path('foo'); 我真的很想避免用ng-click替换网站上所有的href来触发$ location.path('foo'); type functions if possible... 尽可能键入函数...

Anyone else encountered this issue? 其他人遇到过这个问题吗? I'm using AngularJS 1.4.2 我正在使用AngularJS 1.4.2

Thanks! 谢谢!

Please include some code examples where this is occurring. 请包括一些发生这种情况的代码示例。

Replacing all of your ng-href tags with ng-click will probably not address the problem. ng-click替换所有ng-href标签可能不会解决该问题。 It is a busy task at best. 充其量是一项繁重的任务。

If you can find a situation where you can repeatedly reproduce this behavior -- interrogate the browser log for errors. 如果您发现可以重复再现此行为的情况,请在浏览器日志中查询错误。

If you cannot reproduce this behavior -- add a decorator delegate to the $log service that sends your logs to a logging server. 如果无法重现此行为,请在$log服务中添加一个装饰器委托,该委托将您的日志发送到日志服务器。 You will probably only want this decorator enabled in Dev and QA. 您可能只希望在Dev和QA中启用此装饰器。 If you have the infrastructure there are great benefits to doing this in Prod. 如果您拥有基础架构,那么在Prod中执行此操作会带来很多好处。

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

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