Ali Nafees
Ali Nafees

Reputation: 195

Using the tabs in angularjs

I am using the tabs with angularjs. And I am loading view dynamically. What I want is if I have already loaded a view, then with $state.go it should not be loaded again and controller should not run again.It should just be set to active.

View

<tabset> 
  <tab ng-repeat="tab in tabs" select="go(tab.route)" ui-sref-active="tab.active" 
  heading="{{tab.title}}" active="tab.active" disable="tab.disabled"> 
      <ui-view> </ui-view> </tab> 
</tabset> 

JS Controller

$rootScope.tabs = [ { title: 'Dashboard', route: 'store.dashboard', 
         active:true }, { title: 'Home', route: 'store.home' } ]; 

$rootScope.go = function (route) { 
        $state.go(route);
}; 

Upvotes: 1

Views: 365

Answers (1)

Pengyy
Pengyy

Reputation: 38161

for typescript:

let options: angular.ui.IStateOptions = {
  reload: false
};

for javascript:

var options = {
  reload: false 
};

forbid the reload action in $state.go('state', params, options).

Upvotes: 1

Related Questions