0
sophoana created
Hi Support how to assign value and display text in p-autocomplete when edit second form. Cannot display text in p-autocomplete when edit second form.
I'm use: -angular 7 -asp.net core
Source code:
filteredChartOfAccount: NameValueOfString[];
chartOfAccount: any;
html:
<p-autoComplete
id="SingleSelectInput"
name="SingleSelectInput"
field="name"
[(ngModel)]="chartOfAccount"
[suggestions]="filteredChartOfAccount"
(completeMethod)="filterChartOfAccount($event)"
[minLength]="1"
inputStyleClass="form-control"
styleClass="width-percent-100">
<ng-template let-chartOfAccount pTemplate="item">
{{chartOfAccount.name}}
</ng-template>
</p-autoComplete>
.ts:
// get filter
filterChartOfAccount(event): void {
this._chartOfAccountServiceProxy.getChartOfAccountSelectItems(event.query)
.subscribe(chartOfAccountResult => {
this.filteredChartOfAccount = chartOfAccountResult;
});
}
// single select - post
onSelectedChartOfAccounts(): void {
let selectedChartOfAccounts = new Array<NameValueOfString>();
selectedChartOfAccounts.push(this.chartOfAccount);
this._chartOfAccountServiceProxy.sendAndGetSelectedChartOfAccounts(selectedChartOfAccounts)
.subscribe((ChartAccount: NameValueOfString[]) => {
_.forEach(ChartAccount, item => {
this.tax.vatOutChartOfAccountId = parseInt(item.value);
});
});
}
2 Answer(s)
-
1
This should work.
this.chartOfAccount = new NameValueOfString({ name: "DisplayName", value: "1"//value });
-
0
Many thanks support teams @demirmusa