带参数的Angular2管道

带参数的Angular2管道,angular,input,pipe,Angular,Input,Pipe,我正在使用管道,我正在考虑使用带有字符串参数的管道作为@input组件值。大概是这样的: <donut-chart [labels]="portfolio.currentStrategy.assetClasses | strategyFormat:'labels'" [values]="portfolio.currentStrategy.assetClasses | strategyFormat:'percentages'"></donut-chart> 我有一个错

我正在使用管道,我正在考虑使用带有字符串参数的管道作为@input组件值。大概是这样的:

  <donut-chart [labels]="portfolio.currentStrategy.assetClasses | strategyFormat:'labels'" [values]="portfolio.currentStrategy.assetClasses | strategyFormat:'percentages'"></donut-chart>
我有一个错误:

  zone.js:516 Unhandled Promise rejection: Quotes are not supported for evaluation! ; Zone: <root> ; Task: Promise.then ; Value: 
ZoneAwareError {__zone_symbol__error: Error: Quotes are not supported for evaluation! at _AstToIrVisitor.visitQuote (http://localhost:…, __zone_symbol__stack: "Error: Quotes are not supported for evaluation!↵  …2 [<root>]↵    at Array.forEach (native) [<root>]", __zone_symbol__message: "Quotes are not supported for evaluation!"}
 Error: Quotes are not supported for evaluation!
    at _AstToIrVisitor.visitQuote (http://localhost:4200/vendor.bundle.js:18169:15) [<root>]
    at Quote.visit (http://localhost:4200/vendor.bundle.js:38853:24) [<root>]
    at ASTWithSource.visit (http://localhost:4200/vendor.bundle.js:39431:25) [<root>]
    at convertPropertyBinding (http://localhost:4200/vendor.bundle.js:17698:50) [<root>]
    at http://localhost:4200/vendor.bundle.js:81390:165 [<root>]
    at Array.forEach (native) [<root>]
    at bindDirectiveInputs (http://localhost:4200/vendor.bundle.js:81386:25) [<root>]
    at http://localhost:4200/vendor.bundle.js:81565:113 [<root>]
    at Array.forEach (native) [<root>]
    at ViewBinderVisitor.visitElement (http://localhost:4200/vendor.bundle.js:81563:24) [<root>]
    at ElementAst.visit (http://localhost:4200/vendor.bundle.js:7932:24) [<root>]
    at visit (http://localhost:4200/vendor.bundle.js:8213:37) [<root>]
    at http://localhost:4200/vendor.bundle.js:8215:42 [<root>]
    at Array.forEach (native) [<root>]
zone.js:516未处理的承诺拒绝:评估不支持报价;区域:;任务:承诺;价值:
ZoneAwareError{{uuuuuuu zone\u symbol\uuuuuuu错误:错误:求值不支持引号!位于AstToIrVisitor.visitQuote(http://localhost:…,\uuuuu区域\u符号\uuuuuu堆栈:“错误:求值不支持引号!”!↵  …2 []↵    在Array.forEach(native)[]”上,有一条消息:“求值不支持引号!”}
错误:评估不支持引号!
在_asttoivisitor.visitQuote(http://localhost:4200/vendor.bundle.js:18169:15) []
参观(http://localhost:4200/vendor.bundle.js:38853:24) []
在ASTWithSource.visit(http://localhost:4200/vendor.bundle.js:39431:25) []
在convertPropertyBinding(http://localhost:4200/vendor.bundle.js:17698:50) []
在http://localhost:4200/vendor.bundle.js:81390:165 []
在Array.forEach(本机)[]
在bindDirectiveInputs上(http://localhost:4200/vendor.bundle.js:81386:25) []
在http://localhost:4200/vendor.bundle.js:81565:113 []
在Array.forEach(本机)[]
在ViewBinderVisitor.visitElement(http://localhost:4200/vendor.bundle.js:81563:24) []
至少,至少(http://localhost:4200/vendor.bundle.js:7932:24) []
访问(http://localhost:4200/vendor.bundle.js:8213:37) []
在http://localhost:4200/vendor.bundle.js:8215:42 []
在Array.forEach(本机)[]

我也尝试过不使用单引号。但这给了我同样的错误。

我认为错误来自
myPipe
而不是您在问题中发布的标记。请发布
转换(…)
code。可能还有完整的堆栈跟踪,而不仅仅是错误消息。我刚刚编辑了问题。您是否收到
{portfolio.currentStrategy.assetClasses | strategyFormat:'labels'| json}的错误
?字符串插值不是我的情况,因为我使用管道过滤传递到组件输入元素的数据。它仍然会显示错误是来自管道、视图绑定还是来自圆环图组件。我认为错误来自
myPipe
,而不是来自您在问题中发布的标记。请发布<代码>转换(…)code。可能还有完整的堆栈跟踪,而不仅仅是错误消息。我刚刚编辑了这个问题。您是否收到
{{portfolio.currentStrategy.assetClasses | strategyFormat:'labels'| json}的错误
?字符串插值不是我的情况,因为我使用管道过滤传递到组件输入元素的数据。它仍然会显示错误是来自管道、视图绑定还是来自圆环图组件。
  zone.js:516 Unhandled Promise rejection: Quotes are not supported for evaluation! ; Zone: <root> ; Task: Promise.then ; Value: 
ZoneAwareError {__zone_symbol__error: Error: Quotes are not supported for evaluation! at _AstToIrVisitor.visitQuote (http://localhost:…, __zone_symbol__stack: "Error: Quotes are not supported for evaluation!↵  …2 [<root>]↵    at Array.forEach (native) [<root>]", __zone_symbol__message: "Quotes are not supported for evaluation!"}
 Error: Quotes are not supported for evaluation!
    at _AstToIrVisitor.visitQuote (http://localhost:4200/vendor.bundle.js:18169:15) [<root>]
    at Quote.visit (http://localhost:4200/vendor.bundle.js:38853:24) [<root>]
    at ASTWithSource.visit (http://localhost:4200/vendor.bundle.js:39431:25) [<root>]
    at convertPropertyBinding (http://localhost:4200/vendor.bundle.js:17698:50) [<root>]
    at http://localhost:4200/vendor.bundle.js:81390:165 [<root>]
    at Array.forEach (native) [<root>]
    at bindDirectiveInputs (http://localhost:4200/vendor.bundle.js:81386:25) [<root>]
    at http://localhost:4200/vendor.bundle.js:81565:113 [<root>]
    at Array.forEach (native) [<root>]
    at ViewBinderVisitor.visitElement (http://localhost:4200/vendor.bundle.js:81563:24) [<root>]
    at ElementAst.visit (http://localhost:4200/vendor.bundle.js:7932:24) [<root>]
    at visit (http://localhost:4200/vendor.bundle.js:8213:37) [<root>]
    at http://localhost:4200/vendor.bundle.js:8215:42 [<root>]
    at Array.forEach (native) [<root>]