Skip to content

Instantly share code, notes, and snippets.

@0xae
Created March 20, 2015 11:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 0xae/a278be628b9a64fc8972 to your computer and use it in GitHub Desktop.
Save 0xae/a278be628b9a64fc8972 to your computer and use it in GitHub Desktop.
app.controller("AlojamentoCtrl", function ($q, $scope, $localForage, $stateParams){
$scope.alojamentos = [];
var id = $stateParams.idEdificio;
$scope.edificio = id;
$localForage.keys().then(
function (chaves){
var prefixo = "RGA::alojamento::" + id + ".";
var ary = [];
for (var i = 0; i < chaves.length; i++) {
var chave = chaves[i];
if(chave.indexOf(prefixo) != -1){
ary.push($localForage.getItem(chave).then(function (section){ return section; }));
console.log(chave);
}
};
$q.all(ary).then(function (data){
$scope.alojamentos = data;
});
}
);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment