I'm using Ionic framework, and trying to display a list of "Card" elements using the following HTML code:
<div ng-repeat="case in cases">
<div class="list card">
<div class="item item-avatar">
<button ng-click="rmpost(card.key)" style="background: transparent; border: none;"><i class="icon ion-close-round"></i></button><!--if (dataSnapshot.val().volunteer_email == firebase.auth().currentUser.email)-->
<h2>{{card.volunteer_name}} ({{card.volunteer_email}})</h2>
<p>{{card.title}} ({{card.creationdate}})</p>
</div>
<div class="item item-body">
<img class="full-image" src={{card.snapshot}}>
<p>{{card.message}}</p>
</div>
</div>
</div>
This is my JS code used inside the controller for updating the cases array:
.controller('campaignslookCtrl', function($rootScope, $scope, $cordovaGeolocation, $state, $ionicPopup, Util)
{
$scope.reload = function()
{
$scope.reload();
}
$scope.rmpost = function(key)
{
alert("rmpost");
}
$scope.cases = [];
//...
firebase.database().ref('/cases')
.on('child_added', function(dataSnapshot)
{
$scope.cases.push({key: dataSnapshot.key,
volunteer_name: dataSnapshot.val().volunteer_name,
volunteer_email: dataSnapshot.val().volunteer_email,
title: dataSnapshot.val().title,
creationdate: '',//(new Date(dataSnapshot.val().creationdate)).toString(),
snapshot: dataSnapshot.val().snapshot,
message: dataSnapshot.val().message});
});
//..
})
The $scope.cases got well displayed when being initialized to a constant value, but when being dynamically updated (via $push) nothing gets displayed.
dataSnapshotvariable obtained?$watchand refresh on change.