angular - ngx-select-dropdown 设置具有多个值的 displayKey
问题描述
我正在使用ngx-select-dropdown
搜索功能,我想设置多个displayKey
值,例如:firstname
和lastname
.
下面是我的config
对象:
dropdownconfig = {
displayKey: 'firstName, lastName',
search: true,
placeholder: 'Select User',
height: '150px'
};
html:
<ngx-select-dropdown (change)="selecteAdmin($event)" [config]="dropdownconfig" [options]="allUserData" [(ngModel)]="singleSelect" [multiple]="false" ></ngx-select-dropdown>
如何显示多个值displayKey
?此外,需要对该下拉菜单进行验证。
解决方案
在您的数组对象中创建自定义字段。并将其用作密钥。
dropdownconfig = {
displayKey: "custom",
search: true,
placeholder: "Select User",
height: "150px"
};
allUserData = [
{ firstName: 'first1', lastName: 'last1'},
{ firstName: 'first2', lastName: 'last2'},
{ firstName: 'first3', lastName: 'last3'},
{ firstName: 'first4', lastName: 'last4'}
]
ngOnInit() {
for (let user of this.allUserData) {
user['custom'] = user.firstName + ' ' + user.lastName;
}
}
推荐阅读
- snowflake-cloud-data-platform - 描述雪花对象需要哪些授权?
- python - 删除 pandas DataFrame 中的行
- php - 如果存在其他参数,则从自定义帖子类型重写 url 后找不到错误 404 页面
- linux - 我正在尝试遍历目录并对它们执行命令
- python - 具有流数据的数据帧中的数据拆分
- java - 创建自己的数据结构类还是使用现有的实现?
- git - 如何检查 git commit 来自cherry-pick,来自哪个?
- java - 处理在android工具栏中单击菜单项
- python - 使用python编程在csv文件中搜索两个日期和两次之间的记录
- python - 使用 OpenCV 从 HoughLineP 变换中获得所需的角度