【发布时间】:2020-07-17 08:07:01
【问题描述】:
我将整个管道作为参数之一传递,但我很难使用它。
对象格式如下:
{
column: 'productExpirationDate',
caption: 'Product expiration date',
pipe: 'date: \"' + PIPE_DATE_FORMAT + '\"'
},
虽然PIPE_DATE_FORMAT 持有'yyyy-MM-dd',但输出格式应为'date: "yyyy-MM-dd"'
如果我尝试在 html 文件中使用它,例如
<span *ngIf="element.pipe">{{ row[element.column] | element.pipe }}</span>
它大叫
解析器错误:意外的标记“。” ...
我找到了Angular - pass pipe as variable 帖子,但我不知道如何在我的情况下完成这项工作。此外,该答案中使用的get 方法已被弃用,这只会增加更多的混乱。
如何从变量中使用该管道?
【问题讨论】:
标签: angular typescript angular-pipe