我在第一页上有一个链接,当单击该链接时;转到第二页。我在第二页上有两个标签。我想激活第二个选项卡,用户应该直接看到该选项卡的内容。
我已经尝试过使用ui-sref,但它只将我带到第二页。这是我的代码:
第一页:
<a class="modal-trigger" ui-sref=""manage_schedule({'tab' : 'current'})">
<div class="card-action" id="clients-bar">
More Details
</div>
</a>
控制器:
$stateProvider
.state('manage_schedule', {
url : "/manage/schedules/:tab",
templateUrl : "/static/manage_schedule.html",
})
manage_schedule.html
<div ng-controller="ManageSchedule">
<div class="tabslayout rules">
<ul class="tabs">
<li class="tab col s4" ng-click="getPastRuns(profile_log_url)">
<a href="#pastschedular" ng-class="{'active' : selectedTab=='past'}">
Past Runs({{runDetails.past_total}})
<i class="material-icons refresh-center" ng-if="selectedTab=='past'">refresh</i>
</a>
</li>
<li class="tab col s4" ng-click="getRunningSchedules(running_schedules)">
<a href="#runningschedular" ng-class="{'active' : selectedTab=='current'}">
<i class="material-icons refresh-center" ng-if="selectedTab=='current'">refresh</i>
Currently Executing Runs ({{runDetails.current_total}})
</a>
</li>
</ul>
</div>
</div>
<script type="text/javascript">
$(function () {
$("ul.tabs").tabs({});
});
</script>
答案 0 :(得分:0)
路由器
$stateProvider
.state('manage_schedule', {
url: "/manage/schedules/:tab",
templateUrl: "/static/manage_schedule.html",
controller: "ManageSchedule"
});
HTML
<div>
<div class="tabslayout rules">
<ul class="tabs">
<li class="tab col s4" ng-click="getPastRuns(profile_log_url)">
<a href="#pastschedular" ng-class="{'active' : selectedTab=='past'}">
Past Runs({{runDetails.past_total}})
<i class="material-icons refresh-center" ng-if="selectedTab=='past'">refresh</i>
</a>
</li>
<li class="tab col s4" ng-click="getRunningSchedules(running_schedules)">
<a href="#runningschedular" ng-class="{'active' : selectedTab=='current'}">
<i class="material-icons refresh-center" ng-if="selectedTab=='current'">refresh</i>
Currently Executing Runs ({{runDetails.current_total}})
</a>
</li>
</ul>
</div>
</div>
ManageSchedule Controller
controller('ManageSchedule', function ($scope, $stateParams) {
$("ul.tabs").tabs({
active: $stateParams.tab === "current" ? 1 : 0
});
});