下面是数据表中列的代码
<p-column field="organization.description" header="Partner" [editable]="dtCostShare" [style]="{'width':'30%'}">
<ng-template let-col let-csp="rowData" pTemplate="editor">
<span class="required-lbl">* <p-dropdown name="organization" [(ngModel)]="csp.organization.organizationId" (onChange)="addPartnerDescription(csp.index)" [options]="partners" [style]="{'width':'10px'}" appendTo="body" [ngClass]="{'errorCol':csp.organization.organizationId === ''}">
</p-dropdown>
</span>
<span *ngIf="(csp.organization.organizationId === '' )" class="text-danger">Partner is required</span>
</ng-template> </p-column>
ts 代码填充下拉列表
getPartners() {
this.partners.push({ label: 'Please Select', value: '' });
this.parameterService.getPartners().subscribe((data) => {
for (let record of data) {
this.partners.push({ label: record.description, value: record.organizationId });
}
});
}
每当我编辑网格时,下拉菜单都会显示“请选择”而不是显示选定的组织名称。当我打印“csp.organization.organizationId”时,它给出了选定的 organizationId,但 [(ngModel)] 似乎没有设置选定的值。
我哪里错了?