ค้นหาเว็บไซต์

angular - การเปิดหน้าต่างใน Angular2 พร้อม callback


ฉันต้องเปิดหน้าต่างใหม่ ทำบางสิ่งบางอย่างในนั้น และต้องจับเมื่อหน้าต่างนี้ถูกปิดจากลูก

นี่คือโค้ด "พ่อแม่" ของฉัน :

let logonWindow = window.open(url, "_blank", "toolbar=no,scrollbars=yes,resizable=yes,width=400,height=400");
logonWindow.onbeforeunload = this.closing;                        
logonWindow.addEventListener("beforeunload", this.closing, true);

private closing(e) {
  window.location.href = this.storage.get<string>("redirectUrl");
  return null;
}

รหัสลูกของฉัน :

this.http.post(AppSettings.API_BASE + "Login", postData)
.subscribe(res => {

    if (res != null) {
      this.storage.set("token", JSON.parse(res.json()));
      window.close();
    }
  });

และมันก็ไม่เคยเข้าสู่ฟังก์ชัน 'ปิด'

มีไอเดียไหมว่าเพราะอะไร? ฉันสามารถเปลี่ยนอะไรได้บ้างเพื่อให้มันใช้งานได้?