2016-09-10 2 views
0

Hallo ich habe Probleme, wenn ich Daten aus Firebase in console.log ($ scope.statusbaca) abrufen, es 2 Abfrage True und False anzeigen. aber wenn es in der App angezeigt wird, wird es nur falsch angezeigt. Entschuldigung für mein schlechtes Englisch. Englisch ist nicht meine Muttersprache. Ich hoffe, Sie verstehen, mein Problem enter image description here App return false aber Konsole Protokollanzeige wahr und falschAngularjs Firebase-Array-Objekt immer falsch angezeigt

und dies ist mein Code

Vorlage

<div ng-repeat= "item in users"> 
      <div class="list card" style="padding:1%;"> 
       <div class="col-50" style="float:left;"> 

       <h5>{{item.displayName}} - {{item.handphone}}</h5> 
       <h5>{{item.email}}</h5> 
       </div> 
        <div class="col-33" style="float:right; position: relative;" ng-repeat = "datas in statusbaca"> 

        <h5>{{datas}}</h5> 

       </div> 
      </div> 
     </div> 

-Controller

var rootRef = new Firebase('https://example-app.firebaseio.com/'); 
    var childUsers = rootRef.child('users'); 
    var childDate = rootRef.child('tanggal'); 
    var rekapId = $stateParams.rekapId; 
    console.log(rekapId);  

    childDate.child(rekapId).child('tanggalBaca').once('value',function(snap){ 

     $timeout(function() { 
      var snapshot= snap.val(); 
      $scope.tanggal = snapshot;  
      console.log($scope.tanggal); 
      myAfterFunction(); 
     }); 
    }) 

    function myAfterFunction(){ 

    var dates = $scope.tanggal; 
    console.log(dates); 
    var rekapUsers = childUsers.on('value', function(snapshot){ 
     snapshot.forEach(function(childSnapshot){ 
      var key = childSnapshot.key(); 
      console.log(key); 
      var childStatus = childUsers.child(key+'/status/'+dates); 
      childStatus.on('value',function(grandsnap){ 
       var snapval =grandsnap.val(); 
       $scope.statusbaca = snapval; 
       $scope.key = key; 
       console.log($scope.statusbaca); 
       console.log($scope.key); 
       }) 

     }) 
     var snapshotVal = snapshot.val();   
     $scope.users =snapshotVal; 
     console.log($scope.users); 
    })  

    } 

Irgendeine Idee, was mit meinem Code falsch ist und wie man das repariert? Danke

Antwort

0

Ich bin mir nicht sicher, ob dies es beheben wird, aber Ihre div-Elemente sind unausgewogen. Sie sollten eine Endung div-Element wie folgt hinzufügen,

<div class="col-33" style="float:right; position: relative;" ng-repeat = "datas in statusbaca"> 

    <h5>{{datas}}</h5> 

</div> 

Auch kann ich nicht einige der Variablen durch den HTML-Code in der JavaScript und eher verwiesen finden als wie dies Ihr Wert Ausgang:

<h5>{{datas}}</h5> 

sollten Sie es so haben:

<h5>{{datas.THE NAME OF YOUR KEY:VALUE PAIR}}</h5> 

ich kann es nicht testen, da Sie Feuerbasis verwenden, aber, würde ich schnell laufen throug tun h mit deinem Code.