0
I need to take a variable within that function
this.rooms.subscribe(
function (x) {
y= x[0].id;
alert(y)
});
but when access it out of function it returns to its initial value
here the whole code:
openChat(cid, nome) {
let y = ''
this.rooms = this.db.collection<roomMembers>
('room-members', ref => ref.where('uid', '==', this.uid).where('uidOutro', '==', cid)).valueChanges();
this.rooms.subscribe(
function (x) {
y = x[0].id;
alert(y)
}
);
alert(y)
this.navCtrl.push(Chat, {
uid: cid,
nome: nome,
id: y
});
}
And this?
this.db.collection<roomMembers>
? This is not JS. It would be typescript?– bfavaretto