Reputation:
I have this piece of code code
<ng-pluralize count="comment.Comment.like_count"
when="{'0': {{'LIKES_LIKE' | translate}},
'one': {{'LIKES_LIKE' | translate}},
'other': '{{'LIKES_LIKES' | translate}}}">
</ng-pluralize>
but I can't figure out how to Format the string so that it actually parses the likes strings by the translate filter so that the ng-pluralize directive receives the parsed language string.
The error messge is this:
Error: [$parse:lexerr] Lexer Error: Unterminated quote at columns 107-123 [' | translate}}}] in expression [{'0': {{'LIKES_LIKE' | translate}}, 'one': {{'LIKES_LIKE' | translate}}, 'other': '{{'LIKES_LIKE' | translate}}}].
I'm well aware what i means but I can't figure out how to make it work. Any ideas?
Upvotes: 5
Views: 3965
Reputation: 2717
I was looking for the same answer and come up with this solution: Escape the quotes for the translation key with " ;
<ng-pluralize count="comment.Comment.like_count"
when="{'0': '{{"LIKES_LIKE" | translate}}',
'one': '{{"LIKES_LIKE" | translate}}',
'other': '{{"LIKES_LIKES" | translate}}'}">
</ng-pluralize>
or use a ng-int value object (you could also define these values on your controller)
<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>
For interpolation on teh count value you could use
<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>
Where LIKES_LIKES = "{{count}} likes"
http://plnkr.co/edit/TdBPfhqMGuxtWDg28lAV?p=preview
Upvotes: 21
Reputation: 1328
It looks like the first quote here is unterminated: '{{'LIKES_LIKES'
Suggest removing it.
Upvotes: 2