[Solved] Why can’t I access a variable for data binding?
you must have a variable at class level like this export class SampleClass implements OnInit { data: any ; constructor() { } getData() { let request = new XMLHttpRequest(); request.open(‘GET’, ‘https://mywebsite.com/data.json’); request.onload = this.manageData.bind(this); request.send(); } resolveData(ev){ this.data = JSON.parse(ev.target.response); console.log(this.data); } } solved Why can’t I access a variable for data binding?