Reputation: 363
With granted permission, how to read these UIDs? I have tried this with no luck:
//members.ts
export class MembersPage {
user:any = 'wait...';
constructor() {
firebase.database().ref('Accounts').once('value', function(mySnap){
mySnap.forEach(function(uiDSnapshot) {
this.user = uiDSnapshot.key;
console.log(this.user);
});
});
}
//members.html
{{user}}
Upvotes: 1
Views: 89
Reputation: 2633
Your problem is the scope in which you are assigning this.user
. You create a new scope, if you use function()
, try using lambdas/arrow functions instead:
EDIT:
//members.ts
export class MembersPage {
user: [string] = [];
constructor() {
firebase.database().ref('Accounts').once('value', (mySnap) => {
mySnap.forEach((uiDSnapshot) => {
this.user.push(uiDSnapshot.key);
console.log(this.user);
});
});
}
For further information on the scoping problem you might wanna take a look at this.
Upvotes: 1