我需要在页面重新加载后显示活动标签。我发现我需要将活动选项卡名称存储到会话或本地存储中。但对我来说,这不起作用。这是html
<uib-tabset>
<uib-tab active="active" ng-init="isActive = isActiveTab('Info', $index)" index="0" data-toggle="tab" href="#sectionInfo"
heading="Info" classes="tabovi" select="setActiveTab('Info')"></uib-tab>
<uib-tab active="active" ng-init="isActive = isActiveTab('Info 2',$index)" index="1" data-toggle="tab" href="#sectionInfoTwo"
heading="Info 2" classes="tabovi" select="setActiveTab('Info')"></uib-tab>
</uib-tabset>
这是控制器
// Save active tab to localStorage
$scope.setActiveTab = function (activeTab) {
sessionStorage.setItem("activeTab", activeTab);
};
// Get active tab from localStorage
$scope.getActiveTab = function () {
return sessionStorage.getItem("activeTab");
};
// Check if current tab is active
$scope.isActiveTab = function (tabName, index) {
var activeTab = $scope.getActiveTab();
return (activeTab === tabName || (activeTab === null && index === 0));
};
谢谢