Tried to assign a event in a variable but not working.I do not know how to assign.I am getting in console.log(this.myEvents) like null and not able to access closest tr. If anyone know please help to find the solution.
app.component.ts:
public myEvents:any;
logEvent(e)
{
this.myEvents=e; // Store event info
}
// Set a timer for looping through the events
gameTimer = setInterval(function() {
// Loop through events
if(this.myEvents)
{
console.log(this.myEvents);// getting null
}
}, 100)
app.component.html:
<button (click)="logEvent(e)">Set event</button>
Demo: https://stackblitz.com/edit/angular-yqelod?file=src/app/app.component.ts