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

106
Vistas
Angular Javascript return the value of dynamic options on select change

I have a select input and I am using *ngFor on the options to let the user select from an dynamic array I am getting from the database

<select formControlName="destination_id" (change)="onSelectDestination($any($event.target).value)"
    <option *ngFor="let destination of destinations" [ngValue]="destination.id" class="p-3">
        {{ destination.name }}
    </option>
</select>

The function

onSelectDestination(id: any) {
  console.log(id);
}

The problem here is that returns the index of the item and the value

for example: if I chose the third item in the select input it returns this 2: 27

2: is the index and 27 is the id I want

I used substr(3, 2) but it's making problems when the index or the id is bigger than two or three letters

What is the best practice to do this?

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

0

Can you try to replace [value] in place of [ngValue]

value is refer to string and ngValue reference to object which includes the index + value.

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