While I can call a function without any issues, when attempting to call it within setInterval to have it run every second, an error arises: "cannot read property of undefined on the service!"
constructor(private route: ActivatedRoute,private
conversationService:ConversationService) {
}
ngOnInit() {
this.sender = this.route.snapshot.paramMap.get("username");
this.receiver = sessionStorage.getItem("username");
setInterval(
function()
{
this.conversationService.
getTheConversation(this.receiver,this.sender).subscribe(
data=>this.result=data)
},1000);
}
Error: ERROR TypeError: Cannot read property 'getTheConversation' of undefined