下面是我对 PrimeNG p-dropdown 控件的自定义模板设计的标记
<p-dropdown [options]="list" [(ngModel)]="selectedListItem" (onChange)="selectionChanged($event)">
<ng-template let-item pTemplate="selectedItem">
<div class="custom-template-div">
<div class="pull-left location-icon {{item.value.cssClass}}"></div>
<div class="header-line pull-left"><b>{{item.value.text1}}</b></div>
<div class="clearfix"></div>
<div class="detail-line"><i>{{item.value.text2}}</i></div>
</div>
</ng-template>
<ng-template let-item pTemplate="item">
<div class="custom-template-div">
<div class="pull-left location-icon {{item.cssClass}}"></div>
<div class="header-line pull-left"><b>{{item.text1}}</b></div>
<div class="clearfix"></div>
<div class="detail-line"><i>{{item.text2}}</i></div>
</div>
</ng-template>
</p-dropdown>
In this control the <ng-template let-item pTemplate="item">
section is working as expected when the dropdown is listing the items with CSS icons, but when an item been selected, it is not showing in the control, but in the code level the items is selected.
我正在使用如下的自定义 DTO;
export class ListItemDto {
text: string;
text1: string;
text2: string;
value: string;
cssClass: string;
}
我只对<ng-template let-item pTemplate="selectedItem">
模板有问题,因为我试图item.value
直接获取对象item
。两者都不适合我。
任何信息都会有所帮助。谢谢!