我有五个选项卡,它们正常运行。当我刷新页面时,当前活动的选项卡将转换为默认状态。 但我想将它设置为当前活动状态,即使我刷新后也是如此。请让我知道我哪里出错了
Html代码:
<div class="container">
<section ng-app="myApp" ng-controller="TabController as tab">
<ul class="nav nav-pills">
<li ng-class="{active:tab.isSet(1)}"><a href ng-click="tab.setTab(1)">Home</a></li>
<li ng-class="{active:tab.isSet(2)}"><a href ng-click="tab.setTab(2)">Underwriting</a></li>
<li ng-class="{active:tab.isSet(3)}"><a href ng-click="tab.setTab(3)">Operations</a></li>
</ul>
<div ng-show="tab.isSet(1)">
<h4>Home</h4>
</div>
<div ng-show="tab.isSet(2)">
<h4>Underwriting</h4>
</div>
<div ng-show="tab.isSet(3)">
<h4>Operations</h4>
</div>
</section>
</div>
JS:
(function () {
var app = angular.module('myApp', []);
app.controller('TabController', function () {
this.tab = 1; ---> Here I am failing to apply the logic.
this.setTab = function (tabId) {
this.tab = tabId;
};
this.isSet = function (tabId) {
return this.tab === tabId;
};
});
})();
答案 0 :(得分:2)
将标签索引存储在localstorage中,并在页面刷新时再次设置它。因为索引来自本地存储转换为数字的字符串。
this.tab = +localStorage.getItem('tabIndex') || 1;
this.setTab = function (tabId) {
this.tab = tabId;
localStorage.setItem('tabIndex', tabId);
};
这是jsFiddle
答案 1 :(得分:0)
更新了Js
from psycopg2 import sql
cur.execute(
sql.SQL("LISTEN {};")
.format(sql.Identifier(queue_listen_name)))