Javascript AngularJS可以';不要使用散列跳转到锚点

Javascript AngularJS可以';不要使用散列跳转到锚点,javascript,html,angularjs,Javascript,Html,Angularjs,我已经用AngularJS建立了一个网站,我不需要使用路由,所以它没有实现。我希望能够基于锚点跳转到页面中的某个位置,因此我在导航栏中设置了一个链接: <a href="/services#/myAnchor">Jump to anchor</a> 我把它放在更远的地方: <a name="/myAnchor"> 但它不起作用,它必须与AngularJS有关,但由于我没有使用路由,我不知道它是什么。我试着在没有/的情况下使用just#myAncho

我已经用AngularJS建立了一个网站,我不需要使用路由,所以它没有实现。我希望能够基于锚点跳转到页面中的某个位置,因此我在导航栏中设置了一个链接:

<a href="/services#/myAnchor">Jump to anchor</a>

我把它放在更远的地方:

<a name="/myAnchor">

但它不起作用,它必须与AngularJS有关,但由于我没有使用路由,我不知道它是什么。我试着在没有/的情况下使用just#myAnchor,但是Angular似乎在页面加载时加入了它,并且无论如何都不起作用

如何让页面内的基本锚再次工作,有什么想法吗?

您正在寻找:


倒下
你在底部!
角度模块('anchorScrollExample',[])
.controller('ScrollController'、['$scope'、'$location'、'$anchorScroll',
功能($scope、$location、$anchorScroll){
$scope.gotoBottom=函数(){
//将location.hash设置为的id
//要滚动到的元素。
$location.hash('bottom');
//致电$anchorScroll()
$anchorScroll();
};
}]);
。看来你得去散列了
<div id="scrollArea" ng-controller="ScrollController">
  <a ng-click="gotoBottom()">Go to bottom</a>
  <a id="bottom"></a> You're at the bottom!
</div>


angular.module('anchorScrollExample', [])
  .controller('ScrollController', ['$scope', '$location', '$anchorScroll',
    function ($scope, $location, $anchorScroll) {
      $scope.gotoBottom = function() {
        // set the location.hash to the id of
        // the element you wish to scroll to.
        $location.hash('bottom');

        // call $anchorScroll()
        $anchorScroll();
      };
    }]);