Skip to content

Instantly share code, notes, and snippets.

@0xae
Created March 20, 2015 11:26
Show Gist options
  • Select an option

  • Save 0xae/a278be628b9a64fc8972 to your computer and use it in GitHub Desktop.

Select an option

Save 0xae/a278be628b9a64fc8972 to your computer and use it in GitHub Desktop.

Revisions

  1. 0xae created this gist Mar 20, 2015.
    23 changes: 23 additions & 0 deletions alojamentoCtrl.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,23 @@
    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;
    });
    }
    );
    });