1

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);
}; 
2
  • 1
    Please post your routing logic and html Commented Feb 27, 2017 at 2:59
  • <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> $rootScope.tabs = [ { title: 'Dashboard', route: 'store.dashboard', active:true }, { title: 'Home', route: 'store.home' } ]; $rootScope.go = function (route) { $state.go(route); }; Commented Feb 27, 2017 at 3:05

1 Answer 1

1

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).

Sign up to request clarification or add additional context in comments.

6 Comments

Does that also disable reload if user press CTRL+F5
no, Ctrl + F5 will force the browser to reload the whole page.
getting that error Failed to instantiate module store due to: TypeError: Cannot set property 'IStateOptions' of undefined
node: this is for angular-ui-router, the options should be set to the third parameter of the $state.go function.
@AliNafees sorry, that is a typescript code. seems you are using javascript. check for the javascript version.
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.