I am using AngularJS and Ionic framework. I want to create a splash screen but not use cloak
. After showing the splash screen for 10 seconds, my app should go to another page. This second page is designing with Ionic i.e. I use ion-nav-view
, ion-side-menus
, etc.
I don't know how to write this. I searched but couldn't find anything! Please tell me how I can write this or send to me a tutorial.
you have to inject the $location
in your controller or what ever
$timeout(function() {
//will be directed to / after 3 seconds.
$location.path('/');
}, 3000);
I write this but after 3 seconds not change my page. I want to simulate a splash screen!
js:
.config(function ($stateProvider, $urlRouterProvider) {
$stateProvider
.state('welcome', {
url: '/welcome',
//If in a folder, template/welcome.html
templateUrl: 'welcome.html',
controller: 'WelcomeController'
})
.state('splash', {
url: '/splash',
//If in a folder, template/login.html
templateUrl: 'splash.html',
controller: 'LoginController '
})
$urlRouterProvider.otherwise("/splash");
})
.controller('splashControlller', function ($scope) {
$timeout(function () {
//will be directed to / after 3 seconds.
$location.path('/welcome');
}, 3000);
})
html:
<body>
<div>
<ion-nav-view animation="slide-left-right"></ion-nav-view>
</div>
<script id="welcome.html" type="text/ng-template">
<ion-view>
<br /><br />
<h1>Welcome</h1>
</ion-view>
</script>
<script id="splash.html" type="text/ng-template">
<ion-view ng-controller="splashController">
<div class="kit-splash" >
<img class="jouyaSplashImg" alt="" src="Content/images/jouyaSplashImg.png"/>
<span class="splashVersion"></span>
</div>
</ion-view>
</script>
</body>