我之前的代码是这样的:
基本上我将活动状态添加到li docker日志并打开Docker的子菜单。
HTML
<li id="dockerMenu">
<a data-toggle="collapse" href="#docker-pages" aria-expanded="false" aria-controls="testing-main.webapp.pages">
<img src="../resources/img/icons/docker-icon.png" alt="" class="menuIcon">
<span class="menu-title">Docker <i class="fa fa-sort-down"></i></span>
</a>
<div class="collapse" id="docker-pages">
<ul class="nav flex-column sub-menu" data-simplebar>
<security:authorize access="hasAuthority('Administrator')">
<li class="nav-item" id="docker-status">
<a href="/docker-status">
<img src="../resources/img/icons/status.png" alt="">
<span class="menu-title">Container Status</span>
</a>
</li>
...
<ul>
<div>
</li>
var url = window.location.pathname + window.location.search;
if(url === "/docker-logs") {
$('#docker-logs').addClass('active');
$('#dockerMenu a').click();
}
我想在Angular上做同样的事情,但我不知道怎么做
ngOnInit() {
this.toggleMenus();
}
toggleMenus() {
let url = window.location.pathname;
console.log(url);
switch(url) {
case "/docker-logs":
//how do I activate this?
}