Created
October 15, 2014 16:14
-
-
Save jochasinga/e51c240a33f9704b3030 to your computer and use it in GitHub Desktop.
Angularfire three-way binding
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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