gpt4 book ai didi

Angular 5 ng-select 如何将两个值添加到 'bindLabel' ?

转载 作者:太空狗 更新时间:2023-10-29 17:31:55 25 4
gpt4 key购买 nike

我想让 ng-select 在属性 bindLabel 中有两个值。我有这样的东西:

<ng-select placeholder="{{'TASKS.FOR_WHO' | translate }}"
name="users" [items]="users" bindLabel="firstName" >

</ng-select>

但是在bind label 中我想要bindLabel= firstName + lastName。像这样:

<ng-select placeholder="{{'TASKS.FOR_WHO' | translate }}"
name="users" [items]="users" bindLabel="firstName+lastName">

</ng-select>

如何实现?

最佳答案

可以通过自定义标签和项目模板显示它:

<ng-select [items]="users" bindLabel="firstName"> 

<ng-template ng-label-tmp let-item="item">
<span >{{ item.firstName + ' ' + item.lastName }}</span>
</ng-template>
<ng-template ng-option-tmp let-item="item" let-search="searchTerm" let-index="index">
<span >{{ item.firstName + ' ' + item.lastName }}</span>
</ng-template>

</ng-select>

关于Angular 5 ng-select 如何将两个值添加到 'bindLabel' ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51420271/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com