【发布时间】:2014-08-26 19:11:02
【问题描述】:
我正在尝试将 AngularJS $anchorScroll 与 $location.hash 一起使用。但是,当我设置哈希时,AngularJS 会在它之后添加一个正斜杠 /。
例如,网址为:http://localhost:13060/Dashboard。当我不包含 AngularJS 库时,我可以点击链接,#contact,然后转到http://localhost:13060/Dashboard#contact。
但是当我包含 AngularJS 并单击链接时,它会转到 http://localhost:13060/Dashboard#/contact,从而阻止 $anchorScroll 工作。
编辑 $anchorScroll 不起作用
起始 URL 是 http://localhost:13060/Category。
当我添加一个类别时,它应该转到http://localhost:13060/Category#/#id(其中 id 是新的 id)并向下滚动页面到它。 URL 正在正确更新,但 $anchorScroll 没有滚动。
//jump to new category
$location.path("");
$location.hash(cat.ID);
$anchorScroll();
【问题讨论】:
标签: angularjs hashtag anchor-scroll