Primeng dropdown does not load

Asked

Viewed 674 times

1

I think my problem is the HTML page in my Angula project, I can’t help but point out that I’m using the Primeng lib.

See the figure below, it is perfectly loading my list;

inserir a descrição da imagem aqui

But I still can’t load my list into the dropdown primeng

This is my HTML;

       <div class="col-sm-4 col-xs-12">
            <mt-input-container  label="Categorias">
                <p-dropdown [options]="menu.restaurantId"
 name="restaurantId"  placeholder="Selecione"
                [(ngModel)]="menu.restaurantId"
                ></p-dropdown>

            </mt-input-container>
          </div>

The list is loaded by this method.

  ngOnInit() {
    this.getCategorias();
  }

  getCategorias() {
    this.menuAdminService.categoriasMenu().subscribe(
      response => {
        console.log(response.menu)
        if (!response.menu) {

        } else {
          this.menus = response.menu.map( c =>(
            { label: c.name, value: c._id }
          ))
        }
      },
      error => {
        console.log(<any>error);
      }
    );
  }

=====================================UPDATING

I made this change in HTML

   <div class="col-sm-4 col-xs-12">
        <mt-input-container  label="Categorias">
            <p-dropdown [options]="menus" name="restaurantId"  placeholder="Selecione"
            [(ngModel)]="menus"
            ></p-dropdown>

        </mt-input-container>
      </div>

It is loading the list, just not showing as in the image below;

inserir a descrição da imagem aqui

1 answer

1


Looks like you forgot the optionLabel:

<p-dropdown [options]="menus" name="restaurantId"
    optionLabel="name" placeholder="Selecione" [(ngModel)]="menus"
  ></p-dropdown>

Browser other questions tagged

You are not signed in. Login or sign up in order to post.