Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How can use image in Typeahead template? #6261

Open
gaurav-sharp opened this issue Aug 10, 2021 · 0 comments
Open

How can use image in Typeahead template? #6261

gaurav-sharp opened this issue Aug 10, 2021 · 0 comments

Comments

@gaurav-sharp
Copy link

I want to use image along with the name in Typeahead template.

I have the marked code in bold where I wish to use it. If anybody got solution please suggest. here is my code.

This is the sample list

const ImageList: any = [
  { name: 'Mick Rory', path: 'data:image/jpeg;base64,/9j/4AAQSkZJRgAB' },
  { name: 'Sarah Lance', path: 'data:image/jpeg;base64,/9j/4SHHDJZadU' }
]

This is the html

<input type="search" class="form-control" placeholder="Search User" [(ngModel)]="selected"
           [typeahead]="imageList"
           typeaheadOptionField="name"
           [optionsListTemplate]="customListTemplate">
    <ng-template #customListTemplate  let-matches="matches" let-query="query" let-typeaheadTemplateMethods>
      <ul class="participants__input__options" [class.dropdown-menu]="isBs3">
        <li class="participants__input__options__option"
            *ngFor="let match of matches"
            [class.active]="typeaheadTemplateMethods.isActive(match)"
            (click)="typeaheadTemplateMethods.selectMatch(match, $event)"
            (mouseenter)="typeaheadTemplateMethods.selectActive(match)">

<img src={{match.path}}> <span>{{ match.name}} </span>

        </li>
      </ul>
    </ng-template>
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants