How to handle anchor hash linking in AngularJS

后端 未结 27 890
后悔当初
后悔当初 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:18

    Try to set a hash prefix for angular routes $locationProvider.hashPrefix('!')

    Full example:

    angular.module('app', [])
      .config(['$routeProvider', '$locationProvider', 
        function($routeProvider, $locationProvider){
          $routeProvider.when( ... );
          $locationProvider.hashPrefix('!');
        }
      ])
    

提交回复
热议问题