Skip to content
Ember.js and Firebase Integration
Find file
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.


Ember.js and Firebase Integration

This library provides a base Ember.js model that does the retrieving and syncing of your object's property to your specific Firebase location.


Just add the "emberfire.js" file in your html.

<script type="text/javascript" src="./emberfire.js"></script>

Example usage

Sample Firebase location data:

  - person
    - firstName: "Juan"
    - lastName: "Pedro"
    - age: "17"
    - address: "Manila"

[Step 1]
To have an Ember.js model that is Firebase-location-aware, you just have to extend the "EmberFire" model:

Person = EmberFire.extend({});

[Step 2]
Provide these properties to give default values:

  • locationUrl -- property to specify your firebase location.
  • isListItem -- default is false property to tell if this firebase location a list item or not.
  • listId -- needed if isListItem is set to true and it is already existing in the firebase location.
  • modelProperties -- property to enumerate the firebase location properties.
var firebaseLocation = "/myapp";

Person = EmberFire.extend({
  locationUrl: firebaseLocation + "/person",
  modelProperties: ["firstName", "lastName", "age", "address"]

[Step 3]
Once you are done specifying this configuration you can "optionally" add your own properties to your Ember.js model and specify their default values:

Person = EmberFire.extend({
  locationUrl: firebaseLocation + "/person",
  modelProperties: ["firstName", "lastName", "age", "address"]

  firstName: "",
  lastName: "",
  age: 0,
  address: ""

[Step 4]
And then you can create an instance of your model and it will automatically sync any updates on your Ember.js model.

window.App = Ember.Application.create();
App.person = Person.create();

If you want to delete the whole model on your Firebase location just call the "remove()" method.

Something went wrong with that request. Please try again.