如何在ng-select中获取选定的显示值,而不是存储的值?

时间:2019-06-12 12:29:30

标签: angular6 angular5 angular7 angular-ngselect

下面是我使用的下拉列表。

<ng-select [items]="products" bindLabel="code" bindValue="id" placeholder="Select Goods Receipt" clearAllText="Clear" formControlName="productId">
  <ng-template ng-label-tmp let-item="item">
    <span [ngOptionHighlight]="search">{{ item.code }} - {{ item.name }}</span>
  </ng-template>
  <ng-template ng-option-tmp let-item="item" let-search="searchTerm" let-index="index">
    <span [ngOptionHighlight]="search">{{ item.code }} - {{ item.name }}</span>
  </ng-template>
</ng-select>

此处存储的值为 Id ,显示值为代号

我想在json中显示显示值。为此,我使用了以下代码

<pre>{{ goodsReceiptFormGroup?.value.productId | json }}</pre>

但是我无法显示显示值。存储值不是显示值,而是获取。

我需要一种解决方案来获取json中的显示值。有人可以帮我吗?

0 个答案:

没有答案