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

252
Views
Mostrar datos json en menú desplegable usando material angular

Creé un proyecto Angular con material angular y quiero mostrar una lista de unidades dentro de un menú desplegable.

los datos vienen como se esperaba así:

ingrese la descripción de la imagen aquí

este es mi código .ts:

 ListUnits:Array<Unit>=[] units(){ return this.trq.getListUnit().subscribe( (data)=>{ this.ListUnits.push(data.respModel); console.log(this.ListUnits); } )

}

y aquí está mi código .HTML:

 <mat-label>Unite</mat-label> <mat-select formControlName= "unite_id" required> <mat-option *ngFor="let unit of ListUnits"[value]="unit.id"> {{unit.unitName}} </mat-option> </mat-select>

pero lamentablemente no aparece nada ¿Cuáles son los pasos a seguir para lograrlo?

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

0

Estás empujando una matriz dentro de una matriz. En su lugar, haga esto si desea conservar los datos actuales en ListUnits

 this.ListUnits = [...this.ListUnits, ...data.respModel];

De lo contrario, simplemente asigne una matriz de respuesta a ListUnits

 this.ListUnits = data.respModel;
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!