我在自己的路线中针对子状态设置活动状态有困难:
.state( 'sites', {
url: '/sites',
resolve: {
auth: function resolveAuthentication( AuthResolver ) {
return AuthResolver.resolve();
}
},
templateUrl: 'app/components/sites/site.index.html',
controller: 'SiteController',
data: {
requiresLogin: true,
}
})
.state( 'sites.list', {
url: '/list',
resolve: {
auth: function resolveAuthentication( AuthResolver ) {
return AuthResolver.resolve();
}
},
templateUrl: 'app/components/sites/site.list.html',
controller: 'SiteListController',
data: {
requiresLogin: true,
}
})
.state( 'sites.edit', {
url: '/edit/:id',
resolve: {
auth: function resolveAuthentication( AuthResolver ) {
return AuthResolver.resolve();
},
Site: ['$stateParams', 'SiteService',
function( $stateParams, SiteService ) {
return SiteService.getOne( $stateParams.id );
}],
Locations: ['$stateParams', 'LocationService',
function( $stateParams, LocationService ) {
return LocationService.get();
}],
SiteGroups: ['$stateParams', 'SiteGroupService',
function( $stateParams, SiteGroupService ) {
return SiteGroupService.get();
}]
},
templateUrl: 'app/components/sites/site.edit.html',
controller: 'SiteEditController',
params: {
tab: 1
},
data: {
requiresLogin: true,
}
})
我的导航是根据对象数组构建的:
// Build the menu items
$rootScope.menuItems = [
{
name: 'Dashboard',
icon: 'fal fa-tachometer',
url: 'home',
authorisedGroups: ['Marketing'],
divider: false,
children: [],
style: {},
visible: true
},
{
name: 'Sites',
icon: 'fal fa-home',
url: '',
authorisedGroups: ['Marketing'],
divider: false,
children: [
{
name: 'Maintenance',
icon: 'fal fa-edit',
url: 'sites.list',
visible: true
},
{
name: 'Site Groups',
icon: 'fal fa-chart-network',
url: 'siteGroups.list',
visible: true
},
{
name: 'Locations',
icon: 'fal fa-map-marker-alt',
url: 'locations',
visible: true
}
],
style: {},
visible: true
},
...
对于导航数组中的所有对象,使用以下命令可以使active
状态正常运行:
ui-sref-active="active"
当我目前在sites.list
中并且单击某个项目以导航到sites.edit
时,会发生我的问题。我正在尝试针对active
保持sites.list
的状态。
示例,在sites.list
中:
示例,当您单击列表项并移至sites.edit
时:
这可能吗?