2
I’m making a mobile app I already have login working and saving the values I want in Sesssion now I don’t know and how to show these values in 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>
It worked well was really a simple thing that I was complicating. Thank you
– César Sousa
needing am at my disposal @Césarsousa
– Renan Degrandi