Friends, I need to keep an arrangement “session” was using window.localStorage but it has not worked well for me, I do the treatment is as follows:
use this service to save and return my array
.service('misCorredoresService',function(){
var corredores ={};
return {
getCorredores:function(){
return corredores;
},
setCorredores:function(data){
corredores = data;
}
}
})
After consuming the webservice, I handle the data and assessed whether or not I keep in my arrangement.
$scope.resultados = data.list;
var agregar = true;
if($scope.mis_corredores.length <=9){
if($scope.mis_corredores.length > 0 && $scope.mis_corredores.length <=9){
for (var i = 0; i <= $scope.mis_corredores.length-1; i++) {
if($scope.mis_corredores[i].tag == $scope.resultados[0].tag){
agregar = false;
}
};
}
if(agregar){
$scope.mis_corredores.push(data.list[0]);
misCorredoresService.setCorredores($scope.mis_corredores);
$ionicPopup.show({
title: 'Notificación',
subTitle: '',
content: 'El corredor se ha agregado a la lista.',
buttons: [
{
text: 'Aceptar',
type: 'button-positive',
},
]
})
}
}
After that, if the user closed the application I would like to keep the list of users added to the array.
I need help if anyone knows or advise me to do otherwise would greatly appreciate it.
Greetings and thanks for your comments.