好吧,我认为目前还没有任何方法可以在 中指定视图ui-sref
,但这是一个起点,希望对您有所帮助。
首先,路线:
app.config(function($stateProvider, $urlRouterProvider){
$urlRouterProvider.otherwise("/order/all-orders");
$stateProvider
.state("order", { abtract: true, url:"/order", templateUrl:"main.html" })
.state("order.orderTab", { url: "/order-details", templateUrl: "orderDetails.html" })
.state("order.orderAllTab", { url: "/all-orders", templateUrl: "allOrders.html" });
});
然后,定义您的主页(订单和订单详情)[main.html]
<div ng-controller="mainController">
<tabset>
<tab
ng-repeat="t in tabs"
heading="{{t.heading}}"
select="go(t.route)"
active="t.active">
</tab>
</tabset>
<h2>View:</h2>
<div ui-view></div>
</div>
和页面控制器指定选项卡数据:
app.controller("mainController", function($rootScope, $scope, $state) {
$scope.go = function(route){
$state.go(route);
};
$scope.active = function(route){
return $state.is(route);
};
$scope.tabs = [
{ heading: "Order", route:"order.orderTab", active:true },
{ heading: "All Orders", route:"order.orderAllTab", active:false },
];
$scope.$on("$stateChangeSuccess", function() {
$scope.tabs.forEach(function(tab) {
tab.active = $scope.active(tab.route);
});
});
});
您接下来要做的就是将orderID
.
这是一个演示