gsklee / ngStorage

localStorage and sessionStorage done right for AngularJS.
MIT License
2.34k stars 461 forks source link

ngStorage and Firebase working together #232

Open calebeaires opened 7 years ago

calebeaires commented 7 years ago

Would be cool if this module could work with Firebase on something like "three way data binding". Has someone done some work like that.

AngularFire has an bindTo component, maybe this could be the start point.

egilkh commented 7 years ago

I haven't tested it. Does it not work with Firebase?

fassetar commented 7 years ago

I haven't been able to get this to work but maybe I'm doing it wrong. This is what I got so far,

 var ref = firebase.database().ref("GetSummaryData");
$scope.accounts = $sessionStorage.$default($firebaseArray(ref));
console.log($sessionStorage.$default().summary);

but what comes out though is a empty object. Results should just be a array. I believe its because the promise hasn't been resolved before the sessionStorage call?

fassetar commented 7 years ago

Figured it out

 ref.on("value", function(snapshot) {
     $scope.accounts = snapshot.val();
     $sessionStorage.$default($scope.accounts);
     console.log($sessionStorage.$default());
   }, function(errorObject) {
     console.log("The read failed: " + errorObject.code);
   });