My first question and my first "real" project, too. I am using bootstrap, html / css and angular and I have a horizontal menu in unordered list. What I need to do is that this menu has another color in the option that I click, but it did not work using ng-class. It needs to look like this:
where"Start", "Profile" and "Users" are the options and I'm on the start screen in that case.
My code is like this (still incomplete): and I do not know what to use from angular to do this.
(I made a <ul ng-model="classe">
+ <a ng-class="classe"></a>
but did not work)
<div class="menu-superior">
<ul class="nav">
<li><a href="#inicio">Início</a></li>
<li><a href="#2">Perfil</a></li>
<li><a href="#buscar_usuario">Usuários</a></li>
</ul>
</div>
I was able to resolve using
$scope.getClass = function (path) {
if ($location.path().substr(0, path.length) === path) {
return 'active';
} else {
return '';
}
};
no controller and menu
<li><a ng-class="getClass('/buscar_usuario')" href="#buscar_usuario">...</a></li>