简体   繁体   中英

how to change mobile-angular-ui “ui-state” from controller code

I am maintaining a state as follows

<ui-state id='activeScreen' default='1'></ui-state>

I am able to change the state as follows

<a href="#" ui-set="{'activeScreen': 2}">click here</a>

How to change the state from the controller code?

You need to use the SharedState service:

app.controller('myController', function($scope, SharedState){
  SharedState.initialize($scope, "activeScreen", 2);
});

Or:

app.controller('myController', function($scope, SharedState){
  SharedState.set("activeScreen", 2);
});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM