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

223
Vistas
How do I populate angularjs list with for loop or array?

I have the following code someone hard coded:

$scope.years = [
   {id:curryear, name: curryear}
   {id:curryear - 1, name: curryear - 1}
   {id:curryear - 2, name: curryear -2}
];

My task is to populate it so that the HTML dropdown it is linked to can get every year within a certain range. I am pretty new to using angularjs so I am not sure about what I can do with it. Is there a way to iterate through the range, lets say 2020 to 2010 while populating it? Or can I make an array of sets in the JS function this resides in and set $scope.years equal to that>

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

For example you want to start from 2020 and you want to go till 2010:

const years = [{id: 2020, name: 2020}];
for ( let i = 1; i <= 10; i++ ) {
    years.push({id: years[i-1].id - 1, name: years[i-1].name - 1});
 }
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