I have created two templates in AngularJs respectively home.html
and navTemplate.html
.
home.html
<html>
<head>//necessary files goes here</head>
<body ng-app="myApp">
//include navTemplate using ng-include
<ng-include src="'navTemplate.html'"></ng-include>
</body>
</html>
navTemplate.html
<aside id="left-panel">
<nav>
<ul>
<li id="home">
<a href="home.html"><span>Home</span></a>
</li>
<li id="contact" class="active">
<a href="contact.html"><span>Contact</span></a>
</li>
</ul>
</nav>
</aside>
My requirement is that when page is navigated to home.html in nav panel should be updated home as a current page.(add class="active").To do that i have add a script into home.html.
Inside home.html
<script>
$(document).ready(function(){
$("#home").addClass("active");});
</script>
The problem was that this wouldn't add the CSS class into DOM element dynamically if used ng-include
.Please let me know how can i add or remove CSS classes dynamically with ng-include
.