![](/img/trans.png)
[英]Angular2 Router - window.opener: Lost Change Detection at forwar
[英]window Opener Angular2
我需要在Angular 2中將子窗口與父窗口進行通信我很不了解,如何使用window.opener將參數傳遞給angular 2。
在角1.5我用這樣的訪問父
用Javascript這樣的東西
父窗口
<!DOCTYPE html>
<html>
<body>
<h1 id="demo">parent</h1>
<script>
function parentFunction(myVar) {
document.getElementById("demo").innerHTML = myVar;
}
</script>
</body>
</html>
子窗口
<!DOCTYPE HTML>
<html>
<head>
<title>fuente de múltiples elementos</title>
</head>
<body>
<button onclick="window.opener.homeFunction('passVariable')">Click me</button>
</body>
</html>
這是一個很好的答案https://stackoverflow.com/a/39280942/1904479 。 詳細介紹如何在角度2中實現這一點。公開公開一種協作方法,以便從其他來源進行訪問。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.