0
my first question and my first "real" project as well. I am using bootstrap, html/css and angular and have a horizontal menu in an unordered list. What I need to do is that this menu has another color on the option I click, but it didn’t work using ng-class. It needs to look like this:
where "Home", "Profile" and "Users" are the options and I’m on the start screen in this case.
My code is like this (still incomplete): and I don’t know what to use from the angular to do this.
(I made a <ul ng-model="classe">
+ <a ng-class="classe"></a>
but it didn’t 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 managed to solve using
$scope.getClass = function (path) {
if ($location.path().substr(0, path.length) === path) {
return 'active';
} else {
return '';
}
};
in the controller and menu
<li><a ng-class="getClass('/buscar_usuario')" href="#buscar_usuario">...</a></li>
updated my reply from a look.
– Alan Rezende