NOTE: There are many different answers here, and most have been valid at one time or another. The fact is that what works has changed a number of times as the Angular team has changed its Router. The Router 3.0 version that will eventually be 103 router in Angular breaks many of these solutions, but offers a very simple solution of its own. As of RC.3, the preferred solution is to use 101 as shown in 100.
在Angular 应用程序(在我 compose 本文时,当前版本为2.0.0-Beta.0)中,您如何确定当前活动的路由是什么?
我正在开发一个使用Bootstrap4的应用程序,我需要一种方法来标记导航链接/按钮,当它们的相关组件显示在<router-output>
标签中时,导航链接/按钮处于活动状态.
我意识到,当点击其中一个按钮时,我自己可以保持这种状态,但这不包括有多条路径进入同一条路由的情况(比如主导航菜单以及主组件中的本地菜单).
任何建议或链接都将不胜感激.谢谢.