Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

222
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda