I'm trying to implement scrollspy in Angular 4. I've imported jQuery and Bootstrap.js in .angular-cli.json file. Its not giving any error in the console. However active
class is not getting applied to li
element as expected.
https://v4-alpha.getbootstrap.com/components/scrollspy/
header.component.ts
ngOnInit() {
$(document).ready(() => {
$('body').scrollspy({target: "#myNavbar", offset: 50});
});
}
header.component.html
<div class="navbar-collapse" id="myNavbar">
<ul class="nav navbar-nav">
<li><a href="#PATIENT IDENTIFICATION">Section 1</a></li>
<li><a href="#INITIATION">Section 2</a></li>
<li><a href="#section3">Section 3</a></li>
<li class="dropdown"><a class="dropdown-toggle" data-toggle="dropdown" href="#">Section 4 <span class="caret"></span></a>
<ul class="dropdown-menu">
<li><a href="#section41">Section 4-1</a></li>
<li><a href="#section42">Section 4-2</a></li>
</ul>
</li>
</ul>
</div>
<div id="INITIATION"></div>
? – Aldebaran