Quantcast
Channel: Ionic Framework - Ionic Forum
Viewing all articles
Browse latest Browse all 49184

Dismiss stateChangeStart after firing

$
0
0

@anicacute09 wrote:

I am doing an Automatic Login for my app where I save the credentials to localstorage and after running again statechangestart check if localstorage has data and go to the main page. My problem is How can I dismiss the function of statechangestart after it fires because the function runs again if I go to another state and ovewrites the state. Thanks.. here is my code for the checking of localstorage:

$rootScope.$on('$stateChangeStart', function (event, toState, toParams, fromState, fromParams) {

		if (window.localStorage.getItem("username") === null && window.localStorage.getItem("password") === null) {
				console.log('DENY');
				//event.preventDefault();
            	$location.path('/index');
        }
        else {
            	console.log('ALLOW');
            	$location.path('/lounge');
        }
    });

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 49184

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>