如何使选项列表在目标组件中以角度可编辑?

分享于2022年07月17日 angular html picklist primeng 问答
【问题标题】:如何使选项列表在目标组件中以角度可编辑?(How to make picklist editable in the target component in angular?)
【发布时间】:2022-01-26 05:07:49
【问题描述】:

我正在使用 p-picklist ,我想编辑用于显示值的目标列表跨度数据。

我使用的是源码: https://primefaces.org/primeng/showcase/#/picklist

如何使目标列表中的产品名称可编辑。


  
    
{{product.name}}
{{product.category}}
${{product.price}}
{{product.inventoryStatus}}


【解决方案1】:

<h5 class="p-mb-2">{{product.name}}</h5> 转换为 [(ngModel)]="product.name" 的输入似乎可行。

为了检查模板项是否列在 target 下而不是 source 下,您可以检查元素在DOM 上的位置;如果在 .p-picklist-target 内,则显示 input ,否则显示 h5

StackBlitz