When calling a function without any problem,but when call it in setInterval so keep calling it each second it gives me the error: 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