要求:
我们需要在新窗口中打开php页面。我们已经实现了如下所示的方式
.html code
<a target="_blank" href="{{pdf}}">Download Pdf</a>
.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;
}
但我们希望以不同的方式实现它。需要点击html中的一个按钮,它将调用一个函数,从这个函数中应该发生一切。
.html
<button ion-button (click)="saveit">Save</button>
.ts
saveit(){
// the url,html tag should be called from here , how ?
}
答案 0 :(得分:3)
您需要使用window.open
javascript方法在按钮点击时打开网址,如下所示 -
<button ion-button (click)="saveit()">Save</button>
saveit(){
// the url,html tag should be called from here , how ?
window.open(URL);
}
答案 1 :(得分:2)
HTML:
// chagned Type to Nullable<Type>
public static Nullable<Type> GetRes<Type>(Dictionary<string, object> dict, string key)
{
if (dict.ContainsKey(key) && dict[key].GetType() == typeof(Type))
{
return (Nullable<Type>)dict[key];
}
return default(Nullable<Type>);
}
组件:
<button ion-button (click)="saveit()">Save</button>