Angular 主ng下拉列表上的主ng工具提示
我需要在鼠标悬停时显示下拉项目的工具提示。我的html代码如下:-Angular 主ng下拉列表上的主ng工具提示,angular,tooltip,dropdown,primeng,Angular,Tooltip,Dropdown,Primeng,我需要在鼠标悬停时显示下拉项目的工具提示。我的html代码如下:- <p-dropdown [options]="cities2" [(ngModel)]="selectedCity2" optionLabel="name"></p-dropdown> in app.component.ts this.cities2 = [ {name: 'New York', code: 'NY'}, {name: 'Rome', c
<p-dropdown [options]="cities2" [(ngModel)]="selectedCity2" optionLabel="name"></p-dropdown>
in app.component.ts
this.cities2 = [
{name: 'New York', code: 'NY'},
{name: 'Rome', code: 'RM'},
{name: 'London', code: 'LDN'},
{name: 'Istanbul', code: 'IST'},
{name: 'Paris', code: 'PRS'}
];
在app.component.ts中
这是1.cities2=[
{名称:'纽约',代码:'纽约'},
{名称:'Rome',代码:'RM'},
{名称:'London',代码:'LDN'},
{名称:'伊斯坦布尔',代码:'IST'},
{名称:'Paris',代码:'PRS'}
];
我怎样才能做到呢?有什么指示吗
以上内容将仅在字段中直接显示工具提示。。如何在每个下拉项中显示它?我找到了一个解决方案 //假设Cars2类型的carsNew是要绑定到下拉列表的数组。如果需要将ng模板与pdropdown一起使用,则数组的类型应为SelectedItem Interface
interface cars2{
code:string;
description:string
}
carsNew:cars2[];
carsNew2:SelectItem[] = [];
constructor() {
this.carsNew=[
{code:"ABC", description:"ABC Value"},
{code:"DEF", description:"DEF Value"},
{code:"GHI", description:"GHI Value"}
];
}
ngOnInit(): void {
//read through carsNew2 and add it to carsNew2
for(let c of this.carsNew){
this.carsNew2.push({label: (c.code), value: (c.description)} )
}
}
<p-dropdown
[options]="carsNew2"
[(ngModel)]="selectedCar2"
[style]="{'width':'50%'}"
scrollHeight="400px">
<ng-template let-item pTemplate="selectedItem">
{{(item.title) ? 'TODO' : item.label}}
</ng-template>
<ng-template let-car2 pTemplate="item">
<div [pTooltip]="car2.value">
<li><span class="item-value1">{{car2.label}}</span>
</li>
</div>
</ng-template>
</p-dropdown>
接口卡2{
代码:字符串;
描述:字符串
}
carsNew:cars2[];
carsNew2:SelectItem[]=[];
构造函数(){
这是卡斯纽=[
{代码:“ABC”,说明:“ABC值”},
{代码:“DEF”,说明:“DEF值”},
{代码:“GHI”,说明:“GHI值”}
];
}
ngOnInit():void{
//通读carsNew2并将其添加到carsNew2
为了(让c离开这个,carsNew){
this.carsNew2.push({label:(c.code),value:(c.description)})
}
}
{{(item.title)-'TODO':item.label}
{{car2.label}