I need a short delay before a server gets called. I tried using setTimeout:
setTimeout(this.callServer, 1000);
And in the function:
callServer(){
this._item.someVar = "changed";
this._service.deleteItem(this._item)
.subscribe(response => this.onDeleted(response),
error => this.handleError(error));
}
The function gets called but this causes an error:
TypeError: Cannot read property 'someVar' of undefined
And when i log "this" in the console it outputs undefined.
How can I access class methods and member variables after a delay? Is there a better method or some functionality I need to activate first?