简体   繁体   English

窗口开启器Angular2

[英]window Opener Angular2

I need to communicate a child window with parent window in Angular 2 I'm clueless, how to I can use window.opener to pass a parameter to angular 2. 我需要在Angular 2中将子窗口与父窗口进行通信我很不了解,如何使用window.opener将参数传递给angular 2。

In angular 1.5 I used something like this Accessing parent 在角1.5我用这样的访问父

In Javascript something like this 用Javascript这样的东西

Parent Window 父窗口

<!DOCTYPE html>
<html>
  <body>
    <h1 id="demo">parent</h1>
<script>
function parentFunction(myVar) {
    document.getElementById("demo").innerHTML = myVar;
}
</script>
  </body>
</html>

Child window 子窗口

<!DOCTYPE HTML>
<html>
  <head>
    <title>fuente de múltiples elementos</title>
  </head>
  <body>
    <button onclick="window.opener.homeFunction('passVariable')">Click         me</button>
</body>
</html>

Here is a nice answer https://stackoverflow.com/a/39280942/1904479 . 这是一个很好的答案https://stackoverflow.com/a/39280942/1904479 Detailing how this can be achieved in angular 2. Exposing a coponent method publicly so as to be accessed from a different source. 详细介绍如何在角度2中实现这一点。公开公开一种协作方法,以便从其他来源进行访问。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM