我在指令中创建了一个侧边栏,并将ui-sref-active="active"
附加到所有元素。
我必须遇到针对我的状态的问题,或者具有抽象父状态的问题导致ui-sref-active指令无法工作..
在我的路线中,我有:
$stateProvider.
state('main', {
url: '',
abstract: true,
template: '<div ui-view=""></div>',
resolve:{
otherCharts: function($q, $timeout, secondaryCharts){
var deferred = $q.defer();
var charts;
$timeout(function() {
charts = secondaryCharts.getSecondaryCharts();
deferred.resolve(charts);
}, 250);
return deferred.promise;
}
}
}).
state('dashboard', {
parent: 'main',
url: '/dashboard/',
templateUrl: '/app/free/templates/dashboard.html',
controller: function($scope, secondaryCharts){
$scope.secondaryCharts = secondaryCharts.getSecondaryCharts();
},
data: {
name: 'Dashboard'
}
}).
state('growth', {
parent: 'main',
url: '/dashboard/growth',
templateUrl: '/app/free/modules/donor-growth/donor-growth.html',
controller: 'make-donor-growth',
data: {
name: 'Donor Growth',
id: 0,
type: 'chart'
}
})
然后,在我的HTML中,我有:
<li ui-sref="dashboard" ui-sref-active="active" href="/dashboard/" class="title Dashboard"><a "ui-sref="dashboard" href="/dashboard/"><i class="fa fa-tachometer"></i>Dashboard</a></li>
然而,当我在myapp.com/dashboard这样的特定州时,没有添加活动课程。我的目标是哪里出错?
提前致谢!