I want to make navbar active for this i am using css but when i am going to refresh page active tab is going to remove how can i do this in angular 2?
HTML:--
<ul class="nav navbar-nav navbar-top "
*ngFor="let menu of menus">
<li><a href="" (click)="goToPage($event)">{{menu}}
</a>
</li>
</ul>
css:--
navigation a:FOCUS {
box-shadow: 0 -5px 0 -4px #eee;
color: #ffffff;
width:30%
}
.navigation a:HOVER {
box-shadow: 0 -5px 0 -4px #eee;
color: #ffffff;
width:30%
}
您可以使用routerLinkActive
将一些CSS添加到您的活动路由中,例如:
<a routerLink="login" routerLinkActive="active-class">Login</a>
<ul class="nav navbar-nav navbar-top" *ngFor="let menu of menus">
<li>
<a routerLink="menu" routerLinkActive="active">{{menu}}</a>
</li>
</ul>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.