use*_*442 3 typescript ionic-framework ionic2 ionic3 angular
要求:
我们需要在新窗口中打开一个 php 页面。我们已经这样实现了,如下所示
.html code
<a target="_blank" href="{{pdf}}">Download Pdf</a>
Run Code Online (Sandbox Code Playgroud)
.ts code
ngOnInit()
{
this.loggedinuser = localStorage.getItem("USERNAME");
console.log(this.loggedinuser);
this.pdf = 'http://219.90.67.154/report-service/quicktask/TCPDF/examples/test-tcpdf.php?loggedinuser='+this.loggedinuser;
}
Run Code Online (Sandbox Code Playgroud)
但我们想以不同的方式实现它。需要从 html 中点击一个按钮,这将调用一个函数,从这个函数中一切都应该发生。
.html
<button ion-button (click)="saveit">Save</button>
Run Code Online (Sandbox Code Playgroud)
.ts
saveit(){
// the url,html tag should be called from here , how ?
}
Run Code Online (Sandbox Code Playgroud)
您需要使用window.openjavascript 的方法在按钮单击时打开 URL,如下所示 -
<button ion-button (click)="saveit()">Save</button>
saveit(){
// the url,html tag should be called from here , how ?
window.open(URL);
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
10174 次 |
| 最近记录: |