<ng-select tag> 中 BindLabel 的 Angular 6 Concat 字符串

标签 angular concat angular-ngselect

使用 Angular 6,我想在 ng-select 标签 内的 bindLabel 连接 Firstname 和 Lastname

这是我的 html:
ng-select [items]="persons"bindLabel="LastName"bindValue="Id"[(ngModel)]="selectedItem"placeholder="person"

任何想法 ?
bindLabel="LastName + ' ' +FirstName" => 不起作用
bindLabel="person.Name as (person.LastName + ' ' person.FirstName) for person in person" => 不工作

最佳答案

显示全名的更好方法是:

 <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>

关于<ng-select tag> 中 BindLabel 的 Angular 6 Concat 字符串,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50866840/

相关文章:

concatenation - jekyll 在循环中分配 concat?

angular - 如果 ng-select 中列表为空,则隐藏选项列表

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

angular - 无法绑定(bind)到 'ngValue',因为它不是 'option' 的已知属性

angular - 如何使用 Angular ( Angular 2 或 4)路由更改页面标题?

Angular 自定义异步验证器不显示错误

java - 为流中已有的每个元素添加一个元素到流的末尾

video - 贿赂之间的 FFmpeg Concat 伪影

html - 具有可调多列的 Angular 下拉

angular - 如何在 Chrome 中调试 Angular2