我正在使用下面的代码来更新我的剑道自动完成功能。但它在 UI 中显示 [object Object]。
<ng-template kendoGridCellTemplate let-dataItem="dataItem" let-rowIndex="rowIndex">
<kendo-autocomplete #dropDownList [data]="aDirectoryData" [clearButton]="true"
[(ngModel)]="addressDisplayValue[rowIndex]" [disabled]="dataItem.isErroredItem" [allowCustom]="true"
(keyup)="fShippingAddressAutoComplete($event)"
(valueChange)="onValue($event, rowIndex, dataItem)" [value]="[(ngModel)]="addressDisplayValue[rowIndex]"
(click)="fShippingAddress(dropDownValue.value)" (focus)="dropDownList.toggle()">
</kendo-autocomplete>
</ng-template>
addressDisplayValue: string[] = [];
onValue(shippingAdd: IShipToAddresses, rowIndex: number, dataItem: ISalesOrderGroups): void {
this.addressDisplayValue[rowIndex] = '';
const shippingId = 'abcd'
this.addressDisplayValue[rowIndex] = (shippingId + ' ' +
'defgh');
}
但是,当我使用 setTimeOut 时,它可以工作。
setTimeout(() => {
this.addressDisplayValue[rowIndex] = (shippingId + ' ' + 'defgh');
});
由于编码指南,我不能在这里使用 setTimeOut。有替代方法吗?