Today we’re excited to introduce version 1.0 of AngularFire. This new release focuses on enhancing two characteristics of AngularFire: stability and simplicity.
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.
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.
$firebase
$firebaseArray
$firebaseObject
$firebaseAuth
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).
$asArray()
$asObject()
$firebase(ref).$asArray()
$firebaseArray(ref)
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().
$extendFactory()
$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.
new
app.controller("ArrayCtrl", function($scope, ArrayWithSum) { var ref = new Firebase("https://<YOUR-FIREBASE-APP>.firebaseio.com"); $scope.data = new ArrayWithSum(ref); });
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.
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:
require()
var angular = require("angular"); var angularfire = require("../angularfire");
We are providing a migration guide to upgrade from previous versions. The migration guide can be found here.
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.