This is my class :
export class GameControlComponent implements OnInit {
count = 0;
@Output() num = new EventEmitter<number>();
private intervalCall;
ngOnInit(): void {
}
start(): void {
this.intervalCall=setInterval(this.sendNumber, 1000); //works
}
stop(): void {
clearInterval(this.intervalCall); //works
}
sendNumber(this:GameControlComponent){
console.log(this)//windows
this.num.emit(this.count); //this.num undefined
this.count++; // this.count undefined
}
}
Inside of my function sendNumber call by the setInterval function this corresponds to the windows instead of my component so I can't access my properties.
How to get this be equal to my component ?
Thanks guys !