$ location.hash和$ anchorScroll(); URL中没有哈希值

时间:2016-10-19 14:31:48

标签: angularjs

根据$anchorScroll Reference上的内容,我应该能够滚动到哈希而不更新URL(并且不更改路径),但似乎我无法做到。

如果我写

$scope.myFunction = function(id) {
  $location.hash(id);
  $anchorScroll();

我得到哈希和滚动以及路线改变。

如果我写

$scope.myFunction = function(id) {
  $anchorScroll(id);

我没有在网址中获取哈希,也没有滚动。我做错了什么?

0 个答案:

没有答案