jth*_*_92 8 hashtag angularjs anchor-scroll
我试图用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();
Run Code Online (Sandbox Code Playgroud)
除非你使用html5mode,它从角度路由中删除散列,你将有2个哈希值,一个用于角度路由,另一个用于锚点.
http://localhost:13060/Dashboard#/#contact
假设您将路径路径设置为,/profiles并且锚点位于该视图中,则网址将如下所示:
http://localhost:13060/Dashboard#/profiles#contact
| 归档时间: |
|
| 查看次数: |
6422 次 |
| 最近记录: |