Two objects for bindLabel
See original GitHub issueExpected behaviour
Hi Everyone, I would like to know if it was possible to add two object for bindLabel such like that instead of using ng template:
<ng-select [items]="users | async" [multiple]="true" [closeOnSelect]="false" [hideSelected]="true" bindLabel="firstname email" bindValue="_id" placeholder="Select people" [(ngModel)]="userselected" name="sharedUser" required #sharedUser="ngModel">
Actual behaviour
For the moment I use ng template to add both but I would like to keep the same basic style.
<ng-template ng-option-tmp let-item="item" let-index="index" let-search="searchTerm">
<h5>{{item.firstname}} | {{item.email}}</h5>
</ng-template>
More Info
ng-select version: v2.0.0
browser: Mozilla 60.0.2 (64-bit)
Issue Analytics
- State:
- Created 5 years ago
- Comments:5 (1 by maintainers)
Top Results From Across the Web
Angular 5 ng-select how to add two values to 'bindLabel'?
It is possible to display it via a custom label and item template: <ng-select [items]="users" bindLabel="firstName"> <ng-template ...
Read more >@ng-select/ng-select - npm
Angular ng-select - All in One UI Select, Multiselect and Autocomplete. Latest version: 10.0.1, last published: a month ago.
Read more >Data sources
<ng-select [items]="people$ | async" bindLabel="name" autofocus bindValue="id" ... You can also set array of objects as items input ... Selected: "Two" ...
Read more >Data binding basics - .NET MAUI - Microsoft Learn
NET MAUI data bindings allow properties of two objects to be linked so that a change in one causes a change in the...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
In the component.ts, I get all the users from the server which are saved in a list of users (data variable). Then, I iterate through all the items of data and I add another element in the Object User bindName which combine firstname and lastname.
In the HTML, bindLabel="bindName:
this.resourceService.getResources().subscribe(res => { let ress: any[]; ress = res; ress.map((i) => { i.fullName = i.firstname + ' ' + i.lastname; return i; }); this.resources = ress; });
<ng-select [items]="resources" [multiple]="true" name="resource" bindLabel="fullName" bindValue="reference" notFoundText="Aucun élément trouvé" typeToSearchText="tapez plus de 3 caractères pour trouver la resource" [loading]="resourcesLoading" [typeahead]="resourcesInput$" [(ngModel)]="positioning.resourceReference"> </ng-select>