如何从控制器代码更改 mobile-angular-ui "ui-state"

how to change mobile-angular-ui "ui-state" from controller code

我正在维持如下状态

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

我可以按如下方式更改状态

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

如何从控制器代码更改状态?

您需要使用SharedState服务:

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

或者:

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