I am trying to call a function inside the jQuery function. But i am unable use 'this' scope, because it refers to the HTMLElement.
import { Component, Input } from '@angular/core';
import { Injectable } from '@angular/core';
import * as $ from 'jquery';
@Injectable()
export class ChatService {
public chatObj : SomeChatObject;
constructor() { }
disconnect(){
console.log("Chat Disconnected");
}
beforeReload = $(window).bind("beforeunload",function(){
//here 'this' is referred to HTML element. So i am not able to call the disconnect method.
this.disconnect();
});
}
I am not able to access the 'disconnect' method inside jQuery function. How can i call the 'disconnect' method.