I want to open a window, which contains authorization form and handle result of authorization. I decided to do this by checking window location (if user was authorized - this will be updated) because didn't find a better way. But event handler not calling on every event. Can you please tell me why the events don't triggering or some alternative way to intercept the form result?
Might look like a duplication of this question, but in a window the event handlers are not overwritten.
How do I set event handlers:
import { Inject, Injectable } from '@angular/core';
// some other imports
@Injectable({
providedIn: 'root'
})
export class WindowService {
constructor(@Inject(WINDOW) private window: Window) {} // WINDOW is InjectionToken<Window>
open(): void {
let window = this.window.open('https://localhost:7202/Identity/Account/Login', '_blank');
let eventHandler = function() {
console.log(window!.location);
};
window!.onload = eventHandler;
window!.addEventListener('load', eventHandler);
window!.addEventListener('onload', eventHandler);
window!.document.onload = eventHandler;
window!.onhashchange = eventHandler;
window!.addEventListener('hashchange', eventHandler, false);
}
}