1

I am writing a web app using AngularJS on the frontend and I'm implementing a return to top button at the bottom of the page.

   <h1 id = "top">
    ..........
   <a href="#top">Return to Top</a>

However, this does not work at all. I'm lost because this has worked before on other apps that do not use Angular. So do I have to do something different here?

4

2 回答 2

1

Angular 没有任何内在的理由应该干扰链接的本机操作。链接是否可能没有按照您的预期执行,因为在您单击链接时,带有锚点的 h1 元素不再位于 DOM 中?例如,您是否可以使用 ng-if 指令有条件地删除该 h1 标记的父元素或祖先元素?

更新:显然Angular会干涉是有内在原因的。谢谢你的课,@Chandermani。

于 2015-07-11T02:54:24.420 回答
1

将 target="_self" 添加到 href 将解决问题。感谢@Chandermani

于 2015-07-11T05:06:48.517 回答