How to handle anchor hash linking in AngularJS

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

    There is no need to change any routing or anything else just need to use target="_self" when creating the links

    Example:

    Question 1
    Question 2
    Question 3
    

    And use the id attribute in your html elements like this:

    Question 1

    Question 2

    Question 3

    There is no need to use ## as pointed/mentioned in comments ;-)

提交回复
热议问题