[英]Do $window.location.reload(true) after $state.go
I am developing this Ionic/Cordova App where I have to do a reload after $state.go. 我正在开发此Ionic / Cordova应用程序,在其中必须在$ state.go之后重新加载。 I am doing it like this
我这样做
$state.go('app.menu', {}, {reload: true}).then(function(){
$window.location.reload(true);
});
The above code works perfectly fine on a browser, the problem appears when I load it onto an iPhone simulator. 上面的代码在浏览器上可以正常工作,当我将其加载到iPhone模拟器上时出现问题。 The problem is it doesn't go to the specified state ie
app.menu
. 问题是它没有进入指定状态,即
app.menu
。
But if I remove the $window.location.reload(true);
但是如果我删除
$window.location.reload(true);
, it does go the state. ,它确实进入了状态。
What do you think is the problem? 您认为出了什么问题?
Edit: If I add a timeout it works, but I don't want that . 编辑:如果我添加一个超时,它可以工作, 但是我不希望这样 。 Like so
像这样
$state.go('app.menu', {}, {reload: false}).then(function(){
setTimeout(function() {
$window.location.reload(true);
}, 500);
})
Use $timout without delay. 立即使用$ timout。 It works for me.
这个对我有用。
$timeout(function() {
$window.location.reload(true);
});
This worked for me: Source Here . 这对我有用: 在此来源 。
By design, the views are cached. 通过设计,将视图缓存。 Try cache: false in your state.
尝试缓存:在您的状态下为false 。
$stateProvider.state('myState', {
cache: false,
url : '/myUrl',
templateUrl : 'my-template.html'
})
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.