So here's the thing. I have this ng-class on my header item for projects:
ng-class="{ active: $state.includes('project')}"
My main view for projects is called home, the projects themselves are actually under an abstract project state.
Home:
.state('home', {
url: '/',
templateUrl: '/views/project-list-view.html',
controller: 'ProjectListCtrl'
})
Project:
.state('project', {
template: '<ui-view/>',
url: '/project',
abstract: true,
controller: function ($scope) {
//
}
})
.state('project.view', {
url: '/:slug',
params: {
id: null,
slug: null
},
templateUrl: '/views/project-view.html',
controller: 'ProjectViewCtrl'
})
So the problem with this is that when I navigate from my home state (project list) to the project view page, the menu item loses it's active class. When I refresh the page after navigating, it works though. Why is this not working properly and how do I overcome this?
Edit: Had ui-sref-active in the title, but that is not the relevant part that's breaking.
home stateto theproject state, so of course,homeis not active anymore and neitherincludes project state. To get what you want, you'll have to define.state('project')as yourroot/home. So instead of.state('home')change it to.state('project')- Razvan B.