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

131
Vistas
Optgroup with ngFor

I am getting some data from backend that json looks like this:

 {
   "id":1,
   "name":"Colombia La Serrania Omniroast Decaf",
   "manufacturer":{
     "id":16,
     "name":"3fe"
    },
   "manufacturerId":16

I care only about 2 fields: coffee name and manufacturer name, so it is coffee.name and coffee.manufacturer.name What I want to do is to create a select with coffee name options that are grouped by manufacturer name. Something like that: list

Right now I have this:

  <select>
    <optgroup *ngFor="let coffee of CoffeeList" label="{{coffee.manufacturer.name}}">
            <option *ngFor="let item of coffee" [ngValue]="item.id">{{item.name}}</option>
    </optgroup>
  </select>

But obviously it is not working. Gettting: Error: Cannot find a differ supporting object '[object Object]' of type 'CoffeeName'. NgFor only supports binding to Iterables such as Arrays. since coffee isn't iterable. In most of examples I have seen there is usually list inside an object but not in my case. I have no idea how to get it working.

Fetching:

  CoffeeList: any[] = [];

 getCoffeesList(){
    this.service.getCoffees().subscribe(data => {
      this.CoffeeList = data;
    })
  }
about 4 years ago · Juan Pablo Isaza
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