Angularjs routing how to make the navigation highlighted when clicking on the navigation? Thank you first.

take this Baidu as an example, when you click "Page", there is a bottom border at the bottom, which is the effect of the selected highlighted state. I can"t do it well after looking for many examples on the Internet. I"m a little stupid, so I hope you can talk about it.


(1) you can give a type difference when switching navigation. You can add an anchor to url, such as http://localhost:8086/topic/index?nav=XXX. (XXX means click on the nav name)
(2)

<ul>
    <li data-type="wangye" ></li>
    <li data-type="xinwen" ></li>
    <li data-type="tieba" ></li>
</ul>

(3) use the route included in jquery or js or angularjs to get the XXX, in url so that the value of data-type in li is equal to that of XXX. Of course, you can also use id without data-type,. For example:

<ul>
    <li id="wangye" ></li>
    <li id="xinwen" ></li>
    <li id="tieba" ></li>
</ul>

$(XXX) .addClass (highlight class); can treat XXX as id;
(4) benefits: when the page is refreshed, the selected highlight state will not disappear, achieving the desired effect. Disadvantages: the code is not beautiful enough and needs to be optimized and improved


although it has been solved, thank you, brother

.
Menu