我正在实施自定义内容下拉菜单。不能正常工作。它不设置selectedTestType
值,它undefined
在onChangeTestTypes
.
<p-dropdown name="classTestTypeCombobox"
[options]="TestTypes" [(ngModel)]="selectedTestType"
[style]="{'width':'150px'}" filter="filter"
[disabled]="this.isProdCodeDisabled"
appendTo="body"
required
#classTestTypeCombobox="ngModel"
(ngModelChange)="onChangeTestTypes($event)">
<ng-template let-TestType pTemplate="item">
<div class="ui-helper-clearfix" style="position: relative;height: 25px;">
<div>{{TestType.descLong}}</div>
</div>
</ng-template>
</p-dropdown>
TestTypes
是一个类对象数组,它具有以下成员。
id: number;
classificationCode: string;
descLong: string;
classificationParent: string;
codeType: number;
onChangeTestTypes(TestType) {
this.selectedTestTypeDesc = this.TestTypes.filter(x => x.priceCode == TestType)[0].descLong;
this.price.Type = this.TestTypes.filter(x => x.priceCode == TestType)[0].Type;
}