使用 ngx-barcode 在运行时生成条形码

generate barcode at runtime using ngx-barcode

我想遍历循环并从集合中读取连续剧并使用以下代码使用 ngx-barcode 显示它们:

<tbody>
<tr *ngFor="let PS of PrintSerials">
<ngx-barcode [bc-value]="{{ PS.SerialId }}" [bc-display-value]="true"></ngx-barcode>
</tr>
</tbody>

但是我收到这个错误;

NodeInvocationException: Template parse errors: Parser Error: Got interpolation ({{}}) where expression was expected at column 0 in [{{ PS.SerialId }}] in ng:///AppModuleShared/PrintSerialsComponent.html@8:25 (" ][bc-value]="{{ PS.SerialId }}" [bc-display-value]="true"> "): ng:///AppModuleShared/PrintSerialsComponent.html@8:25

如何显示序列条码? 谢谢

将您的代码更改为:

<ngx-barcode [bc-value]="PS.SerialId" [bc-display-value]="true"></ngx-barcode>

正如错误提示的那样,它不应该使用字符串插值来分配 [bc-value]

您需要删除 [bc-value]="{{PS.SerialId}}"[bc-value]="PS.SerialId" 等插值。

这是工作示例:ngx-barcode working example

希望对您有所帮助!!!