In my pages, I have a menu where the landing page menu is initially highlighted. However, when I move to the next menu, the previous landing page highlight remains instead of being removed while swapping the menu. I am using Angular.js and angular ui-router for this functionality.
Below is the code snippet:
<li ui-sref-active="active"><a ui-sref="dashboard">Home</a></li>
<li ng-class="{'active open': $state.includes('dashboard.setting')}"><a ui-sref="dashboard.setting.cat" >Settings</a></li>
<li ng-class="{'active open': $state.includes('dashboard.users')}"><a ui-sref="dashboard.users.view" >User Info</a></li>
Here is my configuration file:
route.js:
var Admin=angular.module('connector',['ui.router', '720kb.datepicker','ngMessages','ngCapsLock','ui.bootstrap','ngFileUpload','angularUtils.directives.dirPagination','angularjs-dropdown-multiselect']);
Admin.run(function($rootScope, $state) {
$rootScope.$state = $state;
});
Admin.config(function($stateProvider, $urlRouterProvider,$locationProvider) {
$urlRouterProvider.otherwise('/');
$stateProvider
.state('/', {
url: '/',
templateUrl: 'view/login.html',
controller: 'loginController'
})
.state('dashboard', {
url: '/dashboard',
templateUrl: 'view/dashboard.html',
controller: 'dashboardController'
})
.state('dashboard.setting', {
url: '/setting',
templateUrl: 'view/setting.html',
controller: 'adminSettingController'
})
.state('dashboard.setting.cat', {
url: '/manage_category',
templateUrl: 'view/manage_category.html',
controller: 'adminCatCategoryController'
})
.state('dashboard.setting.subcat', {
url: '/manage_subcategory',
templateUrl: 'view/manage_subcategory.html',
controller: 'adminSubcatCategoryController'
})
});
Initially, the Home
menu is highlighted. When clicking on the settings
menu, the Home
menu's highlight should be disabled. However, in my case, both menus remain highlighted after clicking on the second menu.
I want only the clicked menu to be highlighted and the landing page menu to stay highlighted initially. The same code works with angular-1.4.6
and angularuirouter-0.2.8
, but I am currently using angular-1.5.9
and angularuirouter-0.3.2
.