How can I append the variable to the href link ? I tried something like -
$scope.downloadFile=(fileName,id)=>{
<a href='https://downloadFile?fileName='+fileName+'&id='+encodeURIComponent(id)></a>;
}
This is not working.
How can I append the variable to the href link ? I tried something like -
$scope.downloadFile=(fileName,id)=>{
<a href='https://downloadFile?fileName='+fileName+'&id='+encodeURIComponent(id)></a>;
}
This is not working.
Using template literals will help make it more readable, but put the backticks on the outside of the whole string. Additionally, when you use arrow functions you can omit the return statement, but only if you avoid using curly braces. Your function wasn't returning anything
$scope.downloadFile = (fileName,id) => `<a href="https://downloadFile?fileName=${fileName}&id=${encodeURIComponent(id)}"></a>`;
Here's a sample in plain JS
const downloadFile = (fileName,id) => `<a href="https://downloadFile?fileName=${fileName}&id=${encodeURIComponent(id)}"></a>`
console.log(downloadFile("THEFILE","THEID"));
Look into Template Literals, it helps making strings more understandable
Try this one:
$scope.downloadFile=(fileName,id)=>{
<a href=`https://downloadFile?fileName=${fileName}&id=${encodeURIComponent(id)}`></a>;
}