"use strict" angular.module('domainManagerApp.domainsData', ['firebase']) .service('Domains', [ '$rootScope', '$firebase', function($rootScope, $firebase) { var domains = []; // Get domain list from firebase var ref = new Firebase("https://j1x-cpanel.firebaseio.com/domains"); ref.on("child_added", function(data) { var domain = data.val(); domains.push(domain); console.log('loading domain: ' + domain.name); $rootScope.$broadcast('domains:loaded', domain); }, function (errorObject) { console.log("The read failed: " + errorObject.code); }); this.get = function() { return domains; } }]);