Introducing AngularFire 1.0

Today we’re excited to introduce version 1.0 of AngularFire. This new release focuses on enhancing two characteristics of AngularFire: stability and simplicity.

Stable API

With a 1.0 release we will guarantee backwards-compatibility with all future 1.x.x releases. We would like to thank those who built amazing apps during the beta. Without your support and feedback AngularFire wouldn’t be what it is today.

Simpler API

The goal of AngularFire is to remove the complexity of synchronizing collections. The 1.0 release removes the overlap between the Firebase SDK and the AngularFire library. AngularFire is now focused on on what it’s good at: synchronized bindings. We’ve removed the $firebase service in favor of two new services: $firebaseArray and $firebaseObject. Authentication through the $firebaseAuth service is already stable and remains unchanged.

$firebaseArray and $firebaseObject

The $firebase service added an unnecessary step to the synchronization process. The 1.0 release cuts right to the chase. If you need a synchronized array, inject the $firebaseArray service and pass it a reference:

app.controller("Ctrl", function($scope, $firebaseArray) {
  var ref = new Firebase("https://<YOUR-FIREBASE-APP>.firebaseio.com");
  $scope.items = $firebaseArray(ref);
});

It’s a similar process to use $firebaseObject to create a synchronized object:

app.controller("Ctrl", function($scope, $firebaseObject) {
  var ref = new Firebase("https://<YOUR-FIREBASE-APP>.firebaseio.com");
  $scope.obj = $firebaseObject(ref);
});

These new services are functionally equivalent to the $asArray() and $asObject() methods present in AngularFire 0.9. For example, the 0.9 $firebase(ref).$asArray() method returns the same array as the 1.0 $firebaseArray(ref).

$extend()

The 0.8 release introduced the $extendFactory() method on arrays and objects. This powerful method provided transformations on AngularFire to fit your own model’s behavior. In the 1.0 release we’ve renamed it to $extend().

script
app.factory("ArrayWithSum", function($firebaseArray) {
  return $firebaseArray.$extend({
    sum: function() {
      var total = 0;
      angular.forEach(this.$list, function(rec) {
        total += rec.x;
      });
      return total;
    }
  });
});

You may notice that the new operator is now optional for $firebaseArray and $firebaseObject. However, when using $extend(), we must always use the new operator.

app.controller("ArrayCtrl", function($scope, ArrayWithSum) {
  var ref = new Firebase("https://<YOUR-FIREBASE-APP>.firebaseio.com");
  $scope.data = new ArrayWithSum(ref);
});

Improved Documentation

We take pride in our documentation at Firebase. Now that AngularFire has hit 1.0, it deserves a guide with an expanded structure that mirrors our other SDKs. We’ve paved the way for continued updates to add relevant samples and sections.

Visit the new docs for a step-by-step development guide on mastering AngularFire.

CommonJS Support

For those of you who love require(), AngularFire 1.0 is the release for you. Angular 1.4 and AngularFire 1.0 now support CommonJS:

var angular = require("angular");
var angularfire = require("../angularfire");

Migration Path from 0.9 to 1.0

We are providing a migration guide to upgrade from previous versions. The migration guide can be found here.

Feedback is welcome

We want to know what you think of the new features. Drop a comment below or send us any feedback on our Angular Google Group.

For more information check out the new in-depth guide. Or for a crash course, visit the AngularFire quickstart or try the five minute tutorial.