I have set of five tabs and they are working properly. When i refresh the page,currently active tab will get shifted to default state. But I want to set it for current active state, even after I refresh. Please let me know where I am going wrong
Html code:
<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;
};
});
})();
working demo : http://jsfiddle.net/fwoxdjsu/