Skip to content

Instantly share code, notes, and snippets.

@jochasinga
Created October 15, 2014 16:14
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save jochasinga/e51c240a33f9704b3030 to your computer and use it in GitHub Desktop.
Angularfire three-way binding
// Register firebase module
var app = angular.module("app", ["firebase"]);
// Set up controller function
app.controller("Ctrl", function($scope, $firebase) {
var firebaseRef = new Firebase(
// Replace this fictional URL with your own
"https://burning-limbo-6666.firebaseio.com/colors"
);
// create an AngularFire ref to the data
var sync = $firebase(firebaseRef);
// pull the data into a local model
var syncObject = sync.$asObject();
// sync the object with three-way data binding
syncObject.$bindTo($scope, "data");
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment