This question already has an answer here:
- How to access the correct `this` inside a callback? 10 answers
I am calling a method in newService and in that method I want to call the method changeMessage. The problem is that in newService.getContentReplies this.newService does not refer to an instance of NewService so it can't read the property of it. What can I do to make this work?
component.ts
newService.getContentReplies(this.parentAuthor, this.parentPermlink)
newService.service.ts
getContentReplies(parentAuthor, parentPermlink){
steem.api.getContentReplies(parentAuthor, parentPermlink, function(err,
result) {
this.newService.changeMessage(result)
}