Saylim Saylim - 1 year ago 361
TypeScript Question

Uncaught TypeError: Cannot set property 'model' of undefined

I have a special problem with a callback method and local variable:

export class Test {

model: Article;

onKeyEnter(value: string) {
this.model.maktx = "Test1";

//This is not working

// Direct call is working
//this.readSuccessCallback(null, null);

find(nr) {

[..other stuff], this.readSuccessCallback, this.errorCallback);

readSuccessCallback(data, response) {
this.model.maktx = "Test2";

value is set correctly when I call
direct from

If the
method is called from the

(SAP Kapsel 3rd Party) an exception occured:

Uncaught TypeError: Cannot set property 'model' of undefined.

Has anyone got an idea what is happening? I don't know exactly what
is doing but it seems that I am not coming back to where I was leaving?

Answer Source

Try this:, this.readSuccessCallback.bind(this), this.errorCallback.bind(this));
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download