I have a database linked to the project with the variable {{PID}}. What I want is to create a function to open external files (URL) that contain this expression in the middle: To open a single file I have:
<ion-button (click)="abrirpdf('https://abcd.com/pids/RS-00020.pdf')">Open {{PID}}</ion-button>
I would like to know how to integrate the variable in my URL if possible, because it doesn't work this way:
<ion-button (click)="abrirpdf('https://abcd.com/pids/RS-{{PID}}.pdf')">Open {{PID}}</ion-button>
TS:
abrirpdf(url:string){
window.open(url, '_system', 'location=yes');
}
CodePudding user response:
Since you already know the PID do it like so.
abrirpdf(){
const myUrl = 'https://abcd.com/pids/RS-' PID '.pdf';
window.open(myUrl, '_system', 'location=yes');
}
And your HTML
<ion-button (click)="abrirpdf()">Open {{PID}}</ion-button>
I suspect you really are iterating over the object, in which case, just pass in the string value of PID into the function.