Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

87
Views
How to append variable with anchor element href link in Angularjs

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.

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

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>;
 }
about 4 years ago · Juan Pablo Isaza Report

0

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"));

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!