I'm using typescript with a regular JavaScript library. The library requires setting a callback function for update notifications. The callback is executing but 'this' is undefined so I can't access any properties of MyComponent within the callback. I'm new to typescript so I don't understand what the problem is.
import { Component, OnInit } from '@angular/core';
export class MyComponent implements OnInit {
myObject:any ={};
constructor() { };
libraryCallback(newObject){
//callback is made but 'this' is undefined
this.myObject = newObject;
}
ngOnInit() {
jsLibrary.setCallback(this.libraryCallback);
}
}