私は AngularJS と Firebase を学習しており、AngularFire 0.8.2 (古いことは知っています) を使用しています。firebase の initAccount と同じ配列を返す関数 (getAccount) が必要です。firebase URL は機能しますが、関数が配列を返すようにする方法がわかりません。どんな助けでも大歓迎です:)
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;
};
});