我有这段代码
<ng-pluralize count="comment.Comment.like_count"
when="{'0': {{'LIKES_LIKE' | translate}},
'one': {{'LIKES_LIKE' | translate}},
'other': '{{'LIKES_LIKES' | translate}}}">
</ng-pluralize>
但我无法弄清楚如何格式化字符串,以便它实际解析翻译过滤器的like字符串,以便ng-pluralize指令接收解析后的语言字符串。
错误消息是这样的:
错误:[$ parse:lexerr] Lexer错误:列的未终止引用 107-123 ['|翻译}}}]在表达式[{'0':{{'LIKES_LIKE'| 翻译}}, 'one':{{'LIKES_LIKE'|翻译}}, 'other':'{{'LIKES_LIKE'|翻译}}}]。
我很清楚我的意思,但我无法弄清楚如何让它发挥作用。有什么想法吗?
答案 0 :(得分:20)
我正在寻找相同的答案并提出这个解决方案: 使用&amp; quot;
转义翻译密钥的引号<ng-pluralize count="comment.Comment.like_count"
when="{'0': '{{"LIKES_LIKE" | translate}}',
'one': '{{"LIKES_LIKE" | translate}}',
'other': '{{"LIKES_LIKES" | translate}}'}">
</ng-pluralize>
或使用ng-int值对象(您也可以在控制器上定义这些值)
<ng-pluralize count="comment.Comment.like_count"
ng-init="likes_like='LIKES_LIKE'; likes_likes='LIKES_LIKE'"
when="{'0': '{{likes_like | translate}}',
'one': '{{likes_like | translate}}',
'other': '{{likes_likes | translate}}'}">
</ng-pluralize>
对于teh计数值的插值,您可以使用
<ng-pluralize count="comment.Comment.like_count"
when="{'0': '{{LIKES_LIKE | translate}}',
'one': '{{LIKES_LIKE | translate}}',
'other': '{{LIKES_LIKES | translate:{count : comment.Comment.like_count} }}'}">
</ng-pluralize>
LIKES_LIKES =“{{count}}喜欢”
答案 1 :(得分:2)
看起来这里的第一个引用是未终结的:'{{'LIKES_LIKES'
建议删除它。