简体   繁体   English

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

[英]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: 您需要使用SharedState服务:

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

Or: 要么:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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