I am trying to make a login for my website. Everything is working and I am currently logged in. Everytime I refresh the page the username and password will dissappear so my login will also dissappear. I do not want that to happen. So what can I do to keep the data in the scopes after a refresh? I get from my php a username password and a permission back and i set the loggedIn to true for my ng-show.
loginController.js
app.controller('loginController', ["$scope", "$http", function($scope, $http){
$scope.info = {
uname :'',
pass : ''
};
$scope.loggedIn = false;
$scope.name ={};
$scope.pass = {};
$scope.logout = function(loggedIn){
loggedIn=false;
};
$scope.users={};
$scope.logThatShitIn = function(info, name){
$http.post("php/userData.php",info)
.success(function(data){
$scope.name = data.user;
$scope.pass = data.pass;
$scope.loggedIn = 'true';
}
);
};
}]);
index.html -> my header
<body ng-controller='loginController'>
<div class="header">
<div class="headerName left">
<div class="headerNameText lname right">
lname
</div>
<div class="headerNameText fname right">
fname
</div>
</div>
<div class="nav left">
<ul>
<li class="navText">
<a ui-sref="dishes">Dishes</a>
</li>
<li class="navText">
<a ui-sref="addRecipe" ng-show='loggedIn'>Add Recipe</a>
</li>
</ul>
</div>
<div class="loginHeader right">
<div class="loginButton" ng-hide='loggedIn'>
<a ui-sref="login">log in</a>
</div>
<div class="logoutButton custFont" ng-show='loggedIn'>
<a href='#' ng-click='loggedIn = false'>log out</a>
</div>
<div class="loggedIn" ng-show='loggedIn'>
<p>welcome {{name}} !!</p>
</div>
</div>
login.html
<div>
<form name="login" ng-submit="logThatShitIn(info)">
<label>Username</label><br/>
<input type=text ng-model="info.uname" placeholder="Username"><br/><br/>
<label>Password</label><br/>
<input type="password" ng-model="info.pass" placeholder="Password"><br/><br/>
<input type='submit' value="Log in!"/>
</form>
<div ng-show='loggedIn'>
{{name}}
</div>