0
我已经有一个home
页面,现在我想要添加一个页面,由localStorage
变量alreadyShown
控制。该设置是在homePlus
首次显示后,我们将alreadyShown
设置为true
,因此homePlus
的所有后期加载都将直接重定向到home
页面。我有以下代码:根据一些条件直接重定向到一个页面
.state('homePlus', {
url: '/homePlus',
templateUrl: '/htmls/homePlus.html',
controller: 'homePlusCtrl',
resolve: {
checkAlready: ['$window', function ($window) {
if ($window.localStorage['alreadyShown'] === "true") {
$window.location.href = "https://localhost:3000/home"
}
}]
}
})
上面的代码不检查alreadyShown
。但是,即使alreadyShown
为true
,在重定向到home
之前,它仍然显示秒的homePlus
页。理想情况下,在这种情况下,我根本不想看到homePlus
页面。
有谁知道如何做到这一点?
它的工作原理,也不要忘了加上'event.preventDefault()'... – SoftTimur