AjRev AjRev - 1 year ago 80
AngularJS Question

Unable to access the object properties returned from firebase

This is probably a noob question as I couldn't find any similar questions here in stackoverflow. I am writing an ionic-angularjs application with firebase as the backend. I've a data snapshot returned by firebase snapshot.val() method and this is how the data shows up in my chrome console(attached pic)

var tmp = {};
CurrUser.getEventdesc(eventid).then(function (result) {
tmp = result;

CurrUser is a factory and getEventdesc is a function in the factory. The getEventdesc function looks like below:

getEventdesc: function(id) {
var deferred = $q.defer();
ref.child('Events').orderByChild('Eventid').equalTo(id).on('value', function (snapshot) {
event = snapshot.val();
return deferred.promise;

enter image description here

Now I'm trying to access the 'Description' property by tmp.Description in my angularjs controller but i get an 'undefined' error. I would be grateful if anyone could help me to access the object properties. Thanks for your time.

Update 2:

var tmp = {};
var newtemp = {};
CurrUser.getEventdesc(eventid).then(function (result) {
tmp = result;
for (var itemID in tmp) {
newtmp = tmp[itemID];


Answer Source

You're retuning the whole firebase object, not just the requested id, try this:

event = snapshot.val();
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download