带有UI

编程入门 行业动态 更新时间:2024-10-24 16:25:59
带有UI-Bootstrap选项卡和UI-Router的Angularjs导航菜单(Angularjs navigation menu with UI-Bootstrap tabs and UI-Router)

在这个Plunker中 ,我无法使菜单链接和标签正常工作。 正如您所看到的,我需要点击两次“路线1”以从标签Route2返回,而且当我点击两次“路线2”菜单链接时,标签内容不会被渲染。

我认为这是代码中相关的重要部分:

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); }); });

In this Plunker, I'm unable to make menu links and tabs to work properly. As you can see I need to click twice the 'Route 1' to go back from tabs Route2, moreover when I click twice the 'Route 2' menu link, the tabs content is not rendered.

I think this is the relevant part of the code that matters:

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); }); });

更多推荐

本文发布于:2023-07-24 19:35:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1250183.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:UI

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!