how to receive window.postmessage event in angular 9


receiveMessage: any = (event: any) => {
//...
}

window.addEventListener("message", () => {
this.receiveMessage();
}, false)

constructor(private _authService: AuthService, private _router: Router) {
if (window.addEventListener) {
window.addEventListener("message", this.receiveMessage.bind(this), false);
} else {
(<any>window).attachEvent("onmessage", this.receiveMessage.bind(this));
}
}

www.codegrepper.com
www.stackoverflow.com