I'm making a mobile app I already have the login working and saving the values I want in session now I do not know and how to show these values on the page after login.
Controller
.controller('LoginInterno', function($scope, $http, sessionService) {
$scope.Btnlogin= function (input){
$http.post("https://www.sabeonde.pt/api/api_login.php?email=" + input.email + "&password=" + input.password).success(function (data) {
$scope.login = data;
userInfo = {
user_id: data.user_id,
nome: data.nome,
user_foto: data.user_foto,
user_slug: data.user_slug
};
sessionService.set('user_id',userInfo.user_id);
sessionService.set('nome',userInfo.nome);
sessionService.set('user_foto',userInfo.user_foto);
sessionService.set('user_slug',userInfo.user_slug);
window.location = "#/app/home"
}).
error(function (data) {
alert("Dados Incorrectos");
});
};
})
sessionService.js
app.factory('sessionService', ['$http', function($http){
return{
set:function(key,value){
return sessionStorage.setItem(key,value);
},
get:function(key){
return sessionStorage.getItem(key);
},
destroy:function(key){
$http.post('data/destroy_session.php');
return sessionStorage.removeItem(key);
}
};
}])
User details
<div class="item item-avatar" ng-controller="LoginInterno">
<img src="mcfly.jpg">
<h2>{{nome}}</h2>
<p>0 Opiniões, 0 Seguidores</p>
</div>