使用Ionic Framework登录/注销时清除历史记录和重新加载页面 [英] Clear History and Reload Page on Login/Logout Using Ionic Framework
问题描述
我是Ionic的移动应用程序开发新手。在登录和注销时我需要重新加载页面,以便刷新数据,但是, $ state.go('mainPage')
将用户带回视图而不用重新加载 - 它背后的控制器永远不会被调用。
I am new to mobile application development with Ionic. On login and logout I need to reload the page, in order to refresh the data, however, $state.go('mainPage')
takes the user back to the view without reloading - the controller behind it is never invoked.
有没有办法清除历史记录并重新加载离子状态?
Is there a way to clear history and reload the state in Ionic?
推荐答案
欢迎使用该框架!实际上,Ionic中的路由由 ui-router 提供支持。您应该查看此前的SO问题找到几种不同的方法来实现这一目标。
Welcome to the framework! Actually the routing in Ionic is powered by ui-router. You should probably check out this previous SO question to find a couple of different ways to accomplish this.
如果您只想重新加载您可以使用的州:
If you just want to reload the state you can use:
$state.go($state.current, {}, {reload: true});
如果你真的想重新加载页面(如你想要重新引导所有内容那么)那么你可以使用:
If you actually want to reload the page (as in, you want to re-bootstrap everything) then you can use:
$window.location.reload(true)
祝你好运!
这篇关于使用Ionic Framework登录/注销时清除历史记录和重新加载页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!