gpt4 book ai didi

angularjs - 如何更改 uib-tabset 中每个选项卡的路由

转载 作者:行者123 更新时间:2023-12-02 22:18:04 33 4
gpt4 key购买 nike

当我选择一个选项卡时,我希望更改 URL。我应该为每个选项卡创建一个状态吗?

这是我的代码,无需更改状态即可正常工作。

我的app.js

var myApp=angular.module('app', ['ui.router','ngAnimate', 'ui.bootstrap']);

myApp.config([
'$stateProvider',
'$urlRouterProvider',
function ($stateProvider, $urlRouterProvider) {

$stateProvider.state('/', {
url: "",
views: {
"ratios": { templateUrl: "views/requetes.html" },
"reqBase": {templateUrl: "views/common.html" },
"SQLconsole": {templateUrl: "views/console.html" },
}

});
$urlRouterProvider.otherwise('/');
}]);



myApp.controller('TabsCtrl', function ($rootScope, $state, $scope, $window) {

$scope.tabs = [
{ title: "ratios", route: "ratios", active: true },
{ title: "requetes de Base", route: "reqBase", active: false },
{ title: "Console", route: "SQLconsole", active: false },
];

});

标签集定义:

<div data-ng-controller="TabsCtrl">    

<uib-tabset>
<uib-tab ng-repeat="tab in tabs" heading="{{tab.title}}" active="tab.active" disable="tab.disabled">
<div ui-view="{{tab.route}}"></div>
</uib-tab>
</uib-tabset>

</div>

最佳答案

试试这个代码:

var myApp=angular.module('app', ['ui.router','ngAnimate', 'ui.bootstrap']);
myApp.config([
'$stateProvider',
'$urlRouterProvider',
function ($stateProvider, $urlRouterProvider) {
$stateProvider
.state('home', {
url:"/",
templateUrl: "views/requetes.html",
})
.state('home.ratios', {
url:"/ratios",
templateUrl: "views/requetes.html",
})
.state('home.reqBase', {
url:"/reqBase",
templateUrl: "views/common.html",
})
.state('home.SQLconsole', {
url:"/SQLconsole",
templateUrl: "views/console.html"
})
$urlRouterProvider.otherwise('/');
}]);

这是工作 PLUNKR对于此代码!!

关于angularjs - 如何更改 uib-tabset 中每个选项卡的路由,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34944379/

33 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com