将angular-2(typescript)全局变量传递给javascript

时间:2018-10-05 02:23:54

标签: javascript html angular typescript ionic-framework

我想要类似Example 1Example 2的东西。 我创建一个离子项目并创建一个.html文件。然后在iframe中的pages / home.ts文件中打开该文件。

pages / home.ts

import { DomSanitizer } from '@angular/platform-browser';

my_url: any;

constructor(private sanitize: DomSanitizer) {
}

urlpaste(){
this.my_url = "assets/imgs/ankur.html";
return this.sanitize.bypassSecurityTrustResourceUrl(this.my_url);
}

pass_to_ankur(){
//how to pass any text in ankur.html file with this function
}

pages / home.html

<ion-content>

<iframe height="100%"  width="100%" [src]="urlpaste()"></iframe>

</ion-content>


<ion-footer>
 <ion-toolbar (click)="pass_to_ankur()">
  <ion-title>Pass variable</ion-title>
 </ion-toolbar>
</ion-footer>

离子项目“ assets / imgs / ankur.html”中的ankur.html文件路径。我想按ankur.html文件中的“传递变量”页脚并传递值。怎么可能。我看到了许多示例,但最大的Android本机是html页面连接性。但是我要从事离子项目。

ankur.html

<!DOCTYPE html>
<html>
 <body>
  <h1>My First Heading</h1>
  <p>My first paragraph.</p>
 </body>
 <script type="text/javascript">
  alert("call==");
 </script>
</html>

请帮忙,因为我尝试了很多天但没有给出任何解决方案。 :(请理解我的问题并解决我的问题。对不起,我的英语不好。谢谢

0 个答案:

没有答案
相关问题