I have this snippet:
usersTempList=[];
ngOnInit() {
this.obj = {user: JSON.parse(localStorage.userDetails),room:"Sala" + this.projectID, projectID: this.projectID};
this.loggedUser = JSON.parse(localStorage.userDetails).UserID;
this.roomList.push(this.obj.room);
this.usersTempList=[];
console.log("Initialized array")
this.join(this.obj);
...
}
join(obj: any){
this.socket.emit("join",obj,this.getOnline);
}
getOnline(err,msg){
console.log(this.usersTempList);
console.log("Printed array");
this.usersTempList = JSON.parse(JSON.stringify(msg));
console.log("qwerty",this.usersTempList);
}
Opening this component on the browser, neither *ngFor works (it isn't printing anything) and, the console.log of the first line of getOnline always prints undefined. Also, even that the variable is updated in the subsequent lines, *ngFor still doesn't update the interface.
Does anyone have any clue about this?
Thanks!