I had the same problem, and this is what I added in my app launch script, and it worked smoothly. Here is the javascript
$(document).ready(function($){
var navs = $('nav > ul.nav');
// Add class .active to current link
navs.find('a').each(function(){
var cUrl = String(window.location).split('?')[0];
if (cUrl.substr(cUrl.length - 1) === '#') {
cUrl = cUrl.slice(0,-1);
}
if ($($(this))[0].href===cUrl) {
$(this).addClass('active');
$(this).parents('ul').add(this).each(function(){
$(this).parent().addClass('open');
});
}
});
});
And the corresponding HTML is shown below. I'm using CoreUI, a phenomenal open source admin template and has support for many front end frameworks like Angular, plain bootstrap, Angular 4 etc.
<div class="sidebar">
<nav class="sidebar-nav open" >
<ul class="nav" id="navTab" role="tablist">
<li class="nav-item">
<a class="nav-link" href="/summary"><i class="icon-speedometer"></i> Dashboard </a>
</li>
<li class="nav-item">
<a class="nav-link" href="/balanceSheet"><i class="icon-chart"></i> Balance Sheet </a>
</li>
<li class="divider"></li>
<li class="nav-title border-bottom">
<p class="h5 mb-0">
<i class="icon-graph"></i> Assets
</p>
</li>
</ul>
</nav>
</div>