angular - 如何将外部变量传递给 Angular Iframe?
问题描述
我创建了一个简单的 Angular 应用程序并将其投入生产。在另一个项目中,我通过 iframe 调用了它。
iframe 显示正确,但我不知道如何将变量传递给 iframe 内的应用程序。
我试过这个:
Parent App
<iframe src="https://{myBusinessUri}.amazonaws.com/index.html?id=12345"></iframe>
Iframe App > App.Module
ngOnInit(): void {
this.getQueryParam();
}
getQueryParam() {
this.activatedRoute.queryParams.subscribe(params => {
const id = params['id'];
console.log(id);
});
}
如果我将 id 添加到 iframe,则会发生错误。
Error: Cannot match any routes. URL Segment: 'index.html'
我还尝试将查询参数 id 放在父应用程序的路径中,但没有成功。
解决方案
推荐阅读
- python - 4 个类,1 个执行操作并请求输入,其他类跟踪值
- javascript - chrome.devtools.network.onRequestFinished 中的 chrome.runtime.sendMessage
- java - 这个 java while 循环在合并排序中做了什么?
- unreal-engine4 - 我在哪里可以阅读有关程序生成关卡的更多信息?
- scala - 在火花 UDF 中获取空指针异常
- android - 定义 NavigationDrawer 行为
- c++ - 在 Qt 中执行图像显示的最佳方法
- python - 在 Pyspark 中按顺序应用多个正则表达式进行文本清理的最快方法
- ruby-on-rails-5 - users_signup_test.rb 在断言 users.reload.activated 时失败。期望假为真。Railstutorial Hartl
- json - AJAX Json 对象在 ASPNET Core 中始终为空