I currently have a home
page set up and now I would like to create a homePlus
page that is controlled by a localStorage
variable called alreadyShown
. The concept is that once the homePlus
page is shown for the first time, we will change the value of alreadyShown
to true
, so that any subsequent loading of the homePlus
page will automatically redirect to the home
page. Below is the code snippet:
.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"
}
}]
}
})
The provided code successfully checks the value of alreadyShown
. However, even when alreadyShown
is set to true
, there is still a brief delay (approximately 0.5-1
second) where the homePlus
page is visible before being redirected to the home
page. Ideally, I would like to completely skip displaying the homePlus
page in this scenario.
Is there a way to accomplish this seamlessly?