firebase/angularFire — pull request #298 by gsklee (2014-04-14 06:04:12+00:00)
Title: Make `$firebase` into a provider and allow object transformation be defined

Usage:

```javascript
angular.module('myApp', ['firebase']).

config(function(
$firebaseProvider
){
// Applies when client is saving to Firebase
$firebaseProvider.transform.onSave = ...

// Applies when client is loading from Firebase
$firebaseProvider.transform.onLoad = ...
});
```

Example (together with `angular-object-key`):

```javascript
angular.module('myApp', ['firebase', 'ObjectKey']).

config(function(
$firebaseProvider,
ObjectKey
){
$firebaseProvider.transform = {
onSave: function(object) {
return ObjectKey.toSnakeCase(object, {
except: /^-/
});
},
onLoad: function(object) {
return ObjectKey.toCamelCase(object, {
except: /^-/
});
}
};
});
```

One thing to bear in mind is that unlike `$http`'s `transformResponse`, which is from JSON to Object, both `onSave` and `onLoad` are Object-in-Object-out, because it works better with Firebase's central concept.