Search icon
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Data Oriented Development with Angularjs

You're reading from  Data Oriented Development with Angularjs

Product type Book
Published in Apr 2015
Publisher
ISBN-13 9781784398057
Pages 156 pages
Edition 1st Edition
Languages

Three-way data binding


You've seen how easy and cool synchronizing the changes from the server is. However, AngularFire takes it a notch further by introducing three-way data binding, whereby it is able to detect local changes, so we don't even have to call $save(). We just have to call $bindTo() on a synchronized object and any changes in the DOM are pushed to Angular and finally to Firebase. Conversely, any changes to the data get pushed to Angular and finally to the DOM.

So let's see it in action. The code for this example is very similar to the one we used in the synchronized arrays example, with a few changes. Here's the modified app.js file:

app.config(function ($routeProvider) {
  $routeProvider
    .when('/', {
      templateUrl: 'main.html'
    })
    .when('/buildings', {
      templateUrl: 'building/buildings.tpl.html',
      controller: 'BuildingsCtrl'
    })
    .when('/buildings/:buildingIndex', {
      templateUrl: 'building/building.tpl.html',
      controller: 'BuildingCtrl...
lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime}