0

My dynamic data isn't updating in header tag. It loads properly the first time but doesn't catch any updates. I have a scope variable that changes from firebase, it console logs the updates but my h1 tag doesnt update. Anybody know whats wrong? Im new to angular and may be using wrong directive? Thank you. Heres my code

//HTML

<div ng-model="len">
            <h2 id="timednum">
                <span>{{ len }}</span>
            </h2> 
</div>

//js
var firebaseRef = new Firebase("https://myApp.firebaseio.com/data");

  firebaseRef.on('value', function(dataSnapshot){

     var tableLength = dataSnapshot.val().data;

       $scope.len = tableLength;
       $scope.$apply(); //SOLUTION!!!!

     console.log("this updates properly" + $scope.len);
   })
}); 

I got the solution, Thanks guys... FOr anybody else struggling checkout the solution or the links in the comments

Yao Ling
  • 1
  • 1
  • Why you are write `console.log("this updates properly" + $scope.line)`? `$scope.line` is not used in **html** template. – Stepan Kasyanenko Mar 14 '16 at 03:58
  • See http://stackoverflow.com/questions/27011835/angularjs-does-not-update-after-value-change or http://stackoverflow.com/questions/27156491/firebase-get-data-for-every-child-items-child/27172348#27172348 or http://stackoverflow.com/questions/27432740/firebase-binding-not-being-reflected-in-angular-view/27433610#27433610 – Frank van Puffelen Mar 14 '16 at 04:02
  • Sorry @Stephan that was a typo – Yao Ling Mar 14 '16 at 04:10

0 Answers0