我在我的 Angular 5 项目中使用包ngx 选择下拉菜单,并想知道如何传递对象数组而不是字符串数组。目前,如果我这样做,它会在下拉菜单中将 [Object Object] 显示为选项。
data=[ {
"id": "ab",
"description": "аҧсуа"
},
{
"id": "aa",
"description": "Afaraf"
},
{
"id": "af",
"description": "Afrikaans"
},
{
"id": "ak",
"description": "Akan"
}]
<ngx-select-dropdown [config]="config" [options]="data" [(ngModel)]="datasel" [multiple]="false">
</ngx-select-dropdown>
/** ngx-select-dropdown config */
public config: any = {
search: true,
height: '260px',
placeholder: 'Select',
customComparator: () => { },
limitTo: 10,
moreText: 'more',
noResultsFound: 'No results found!',
searchPlaceholder: 'Search',
searchOnKey: ''
}
我想在下拉列表中和选择获取所选选项的 id 时向用户显示描述。