Lazy listbox with images?

UI Components for Angular
Post Reply
IanTheG
Posts: 2
Joined: 23 Nov 2021, 05:03

23 Nov 2021, 05:09

I'm testing out a Pokemon web app to learn Angular 13 and PrimeNG. Each Pokemon item is loaded with a small sprite and its name, there are over 1000 in this list! The [filter]="true" option is great for this component.

Is it possible to lazy load listbox items? If not, is there another component that can accomplish the same task?

Code: Select all

<p-listbox
      [options]="list"
      [(ngModel)]="selectedPokemon"
      [multiple]="false"
      [filter]="true"
      optionLabel="name"
      [listStyle]="{ 'max-height': '200px' }"
    >
      <ng-template let-pokemon pTemplate="item">
        <div class="pokemon-item" (click)="getDetails(pokemon)">
          <img [src]="'assets/sprites/' + pokemon.sprite" />
          <p>{{ pokemon.name | titlecase }}</p>
        </div>
      </ng-template>
    </p-listbox>

Post Reply

Return to “PrimeNG”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 7 guests