Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

90
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda