0
I’m developing a project and I’m using Angular, I need when accessing the internal page, the menu is selected, until then beauty, but the problem is when the internal page contains Lug or some internal, follow code I’m using:
Html:
<li class="waves-effect waves-light" ng-class="(url_atual == '/module9'? fundo_selecionado:fundo_normal)">
<img src="app/template/img/col.png">
<p>Colaboradores</p>
</li>
Controller:
$scope.url_atual = $location.url();
$scope.fundo_selecionado = 'fundo_selecionado';
$scope.fundo_normal = 'fundo_normal';
CSS:
.fundo_selecionado{
background-color: #fff!important;
}
.fundo_normal{
background-color: $cor_cinza!important;
}
As you can see, I use an ng-class and if the current url is equal to the module accessed, it plays the selected base_class, otherwise it plays the normal base_class. The problem is when I have internal module, such as /module9/internal or module9/Lug that there it does not keep the selected menu. Does anyone have a hint on how to keep the selected menu even in the built-in modules?
Follows a route system:
function Config($routeProvider) {
$routeProvider
.when('/module9', {
templateUrl: 'module9/template/index.html',
controller: 'module9Controller',
controllerAs: 'vm'
})
.when('/module9/:module9Slug', {
templateUrl: 'module9/template/interna.html',
controller: 'module9Controller',
controllerAs: 'vm'
})
.when('/module9/adicionar/add', {
templateUrl: 'module9/template/adicionar.html',
controller: 'module9Controller',
controllerAs: 'vm'
});
}
Is this it? ng-class="(currenturl_== '/module9' || currenturl_== '/module9/internal or module9/Slug' ? fundo_selected:fundo_normal)"
– PauloHDSousa
Which route system, or how navigation in your project is done?
– celsomtrindade