I am learning AngularJS and Firebase and using AngularFire 0.8.2 (Old I know). I want a function (getAccount) to return an array identical to initAccount from firebase. The firebase URL works but I don't know how to make the function return the array. Any help would be appreciated :)
app.service('DataService', function(FURL, $firebase) {
var ref = new Firebase(FURL);
//initial account array to load
this.account = [
{'info':'Sig1'},
{'info':'Sig2'},
{'info':'Sig3'}
];
this.getAccount = function(user) {
var uid = user.uid;
var dir = 'profile/' + uid + '/account';
var accountSigs = $firebase(ref.child(dir)).$asArray().$loaded().then(function(response) {
//show response returns [[object Object],[object Object],[object Object]] with correct data as it should.
console.log('show response: [' + response + ']');
return response;
});
// this returns [[object Object]] but I don't know why
console.log('show accountSigs: [' + accountSigs + ']');
return accountSigs;
};
});