Skip to content

Instantly share code, notes, and snippets.

@jondthompson
Created October 24, 2015 23:36
Show Gist options
  • Save jondthompson/1cdbe5304b894aa8cae2 to your computer and use it in GitHub Desktop.
Save jondthompson/1cdbe5304b894aa8cae2 to your computer and use it in GitHub Desktop.
issue in iron-chrome-storage
.controller( 'HomeCtrl', function HomeController( $scope, $firebaseArray, $firebaseObject, chromeStorage ) {
var ref;
Firebase.INTERNAL.forceWebSockets();
var storage;
chromeStorage.getOrElse('storage', function() {
var keyValue = {
path: 'demo',
key: 'unknown'
};
return keyValue;
}).then(function(keyValue) {
// do something with the key value
storage = keyValue;
ref = new Firebase("https://.../"+ storage.path);
// download the data into a local object
$scope.floors = $firebaseArray(ref.child('floors'));
$scope.building= $firebaseObject(ref);
$scope.format = 'M/d/yy h:mm a ';
});
})
@jondthompson
Copy link
Author

Here's how I got around it.

.controller( 'HomeCtrl', function HomeController( $scope, $firebaseArray, $firebaseObject, chromeStorage ) {
     var ref;
     Firebase.INTERNAL.forceWebSockets();
     chromeStorage.get('storage').then(function(result){
      if(result)
      {
        console.log('Chrome storage retrieved');
        console.log(result);
        storage = result;

     }else{
      console.log('Setting Chrome Storage');
      storage = {
          path: 'demo',
          key: 'unknown'
        };
      chromeStorage.set('storage',storage);
     }


    ref = new Firebase("https://.../"+ storage.path);
  // download the data into a local object
  $scope.floors = $firebaseArray(ref.child('floors'));
  $scope.building= $firebaseObject(ref);
     }); 
  $scope.format = 'M/d/yy h:mm a ';
})

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment