在this Plunker中,我无法使菜单链接和选项卡正常工作。 正如你所看到的,我需要点击两次“路线1”从标签路线2返回,而且当我点击两次“路线2”菜单链接时,标签内容不会呈现。带UI-Bootstrap选项卡和UI-Router的Angularjs导航菜单
,我认为这是代码的相关部分的事项:
myapp.config(function($stateProvider, $urlRouterProvider) {
$urlRouterProvider.otherwise("/");
$stateProvider
.state('route1', {
url: "/",
templateUrl: "route1.html"
})
.state('DocumentoMasterView', {
url: "/route2",
templateUrl: "route2.html",
controller: 'myAppController'
})
.state('DocumentoMasterView.A', {
url: '/detail',
templateUrl: 'route2.A.view.html',
controller: 'myAppController'
})
.state('DocumentoMasterView.B', {
url: '/image',
templateUrl: 'route2.B.view.html',
controller: 'myAppController'
})
.state('DocumentoMasterView.C', {
url: '/submenu',
templateUrl: 'route2.C.view.html',
controller: 'myAppController'
})
});
myapp.controller('myAppController',['$scope','$state',function($scope, $state){
$scope.tabs = [
{ heading: 'A View', route:'DocumentoMasterView.A', active:true},
{ heading: 'B View', route:'DocumentoMasterView.B', active:false },
{ heading: 'C View', route:'DocumentoMasterView.C', active:false }
];
$scope.go = function(route){
$state.go(route);
};
$scope.active = function(route){
return $state.is(route);
};
$scope.$on('$stateChangeSuccess', function() {
$scope.tabs.forEach(function(tab) {
tab.active = $scope.active(tab.route);
});
});
@Radim_Köhler这是一个很大的进步,最后一两件事:当你在“路线2”两次单击选项卡的内容消失。 – Cris69 2014-09-06 07:58:33
我引入了另一个特性“重定向”*(更新了我的第一个plunker)*,如果选择route2,它将始终导航到第一个选项卡:'$ urlRouterProvider.when(“/ route2”,“/ route2/detail” );'希望它有帮助;]享受'ui-router' – 2014-09-06 10:28:59
该解决方案仍然存在一些问题,例如点击两次相同的选项卡切换到下一个选项卡,并且选项卡未正确呈现。我发现了一个更好的解决方案[这里](http://stackoverflow.com/questions/25017382/tabs-in-angularjs-not-working-properly-with-ui-router-and-ui-bootstrap)。 – Cris69 2014-09-11 08:32:20