0

イオンベースのファイヤーベースと角度の使用に問題があります。私が達成したいのは、ユーザが日付のリストをクリックした後、例8を表示すると、ユーザは8 septのすべての出席状況を見ることができます。ユーザーがクリック9月8日の後ファイヤーベース角を使用した出席チェック

List of dates

。ユーザーデータのリストと出席状況が8 septに表示されます。

After user click one of the dates it show the attendance list and their status

これはこれまでのところ、私はすべての日付とユーザーデータの一覧を表示することができ、私のfirebaseデータベース

this is my firebase database

です。しかし、問題は私のクエリがすべての日付のステータスを表示することです(8 & 9月9日)。選択した日付のステータスのみを表示する方法は?

これは私が取り組んでいる私のコードです。

Controller.js

childUsers.orderByValue().on('value', function(snapshot){ 
    $timeout(function(){ 

     var snapshotVal = snapshot.val(); 

     $scope.users =snapshotVal; 
     console.log($scope.users); 

     }); 
    }); 

テンプレート

<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; "> 

        <div ng-if="item.status = 'true'"> 
         <div class="ion-checkmark" style="display: flex; vertical-align: middle;"></div> 
        </div> 

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

この問題を解決するためにどのように任意のアイデア?ありがとうございました。

答えて

0

私はここに、ネストされたスナップショットを使用して解決策を見つけたが、私のコード

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); 
    })  

    } 
関連する問題