Created
March 20, 2015 11:26
-
-
Save 0xae/a278be628b9a64fc8972 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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