I have this scope problem. I understand that the lines "this.catVotes = catData" is inside another function so I can't send it directly to "catVotes: Number;"
How can I solve this?
catVotes: Number;
dogVotes: Number;
constructor(private votingService: VotingService, private socket: Socket) { }
ngOnInit() {
this.socket.on('catvotes', function(catData){
console.log(catData);
this.catVotes = catData;
});
this.socket.on('dogvotes', function(dogData){
console.log(dogData);
this.dogVotes = dogData;
});
}