Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Angular 6 Concat string for BindLabel in <ng-select tag>

Using Angular 6, I want to concat Firstname and Lastname in bindLabel inside ng-select tag ?

Here is my html : ng-select [items]="persons" bindLabel="LastName" bindValue="Id" [(ngModel)]="selectedItem" placeholder="person"

Any idea ? bindLabel="LastName + ' ' +FirstName" => doesn't work bindLabel="person.Name as (person.LastName + ' ' person.FirstName) for person in persons" => doesn't work

like image 436
cn-ge Avatar asked Dec 14 '22 16:12

cn-ge


1 Answers

A better way for display the full name is:

 <ng-select required [items]="buddies" bindLabel="firstName" #buddiesInput="ngModel" [(ngModel)]="userSelect" name="userSelect" >
                        <ng-template ng-label-tmp let-item="item">
                            {{item.firstName}} {{item.lastName}}
                        </ng-template>
                        <ng-template ng-option-tmp let-item="item" let-search="searchTerm">
                            {{item.firstName}} {{item.lastName}}
                        </ng-template>
                    </ng-select>
like image 70
Longo Avatar answered Dec 25 '22 03:12

Longo