I am trying to implement a simple login feature. I want to have the DOM load a different element based on whether the $window.sessionStorage.currentUserId5 session exists or not. But the conditional statement I have added to .run() just keeps using the else{} statement
<script>
var app = ons.bootstrap('app', ['onsen','angular-svg-round-progress','nvd3','ngStorage']).run(function($rootScope,$window){
if($window.sessionStorage.currentUserId5)
{
$("#menudiv").html('<ons-sliding-menu var="menu" id="menusliding" main-page="main.html" menu-page="menux.html" max-slide-distance="85%" type="reveal" side="left" ></ons-sliding-menu>');
}
else{
$("#menudiv").html('<ons-sliding-menu var="menu" id="menusliding" main-page="login.html" menu-page="menux.html" max-slide-distance="85%" type="reveal" side="left" ></ons-sliding-menu>');
}
});
</script>
<div id="menudiv"></div>
Controller
User clicks button and this is called, $window.sessionStorage should be created here
$http.post('http://xxx-xxx.us-east-1.elasticbeanstalk.com/apipost/checkuserlogin', parameter, config).success(function (data, status, headers, config) {
// if login, user session created, redirected to index.html
if(data['result'] == 'success'){
$window.sessionStorage.currentUserId5 = '5'
$window.location.reload();
}
else {
// else error pop up
ons.notification.alert({
message: 'Please try again'
});
}
})
.error(function (data, status, header, config) {
});