How to handle anchor hash linking in AngularJS

后端 未结 27 1140
后悔当初
后悔当初 2020-11-22 12:22

Do any of you know how to nicely handle anchor hash linking in AngularJS?

I have the following markup for a simple FAQ-page



        
27条回答
  •  悲&欢浪女
    2020-11-22 13:09

    On Route change it will scroll to the top of the page.

     $scope.$on('$routeChangeSuccess', function () {
          window.scrollTo(0, 0);
      });
    

    put this code on your controller.

提交回复
热议问题