I am using @ng-select/[email protected] in my application and i have a very long text in array.
So, the complete text not visible in dropdown list so I want to show the title/ tooltip over the each and every options
I tried,
let listArray = [{name: 'Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s'}];
<ng-select placeholder="Select" (change)="onChange($event)">
<ng-option *ngFor="let list of listArray"
title="{{list.name}}"> {{list.name}} </ng-option>
</ng-select>
But no luck
This question is old, but using span could be another solution:
<ng-select placeholder="Select" (change)="onChange($event)">
<ng-option *ngFor="let list of listArray"
title="{{list.name}}"><span [title]="list.name">{{list.name}}</span></ng-option>
</ng-select>
you can achieve tooltip solution using below code
<ng-select [items]="listArray" bindLabel="name" bindValue="name">
<ng-template ng-option-tmp let-item="item">
<div title="{{item.name}}">{{item.name}}</div>
</ng-template>
</ng-select>
Thanks
You can put a template inside the <ng-option>
, and add the directive ng-option-tmp
:
<ng-select [items]="listArrayManyElements" placeholder="Select" [(ngModel)]="Selected"
bindLabel="name" bindValue="name">
<ng-template ng-option-tmp let-item="item">
<div [title]="item.name">{{item.name}}</div>
</ng-template>
</ng-select>
I've updated your stackblitz
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With