Reputation: 670
In .js files triple nested quotes ("one'two"three"'") can be escaped (see this post) and in HTML this can also be achieved using character references (see this post). I have a problem achieving this in an AngularJS expression in my template.
I need to put this:
{{ 'PLURAL' | translate:"{ GENDER: 'male' }":"messageformat" }}
Into a placeholder element:
<input placeholder="{{ 'PLURAL' | translate:"{ GENDER: 'male' }":"messageformat" }}">
How should I escape the quotes to make it work?
Upvotes: 5
Views: 4931
Reputation: 136174
Answer would be put { GENDER: 'male' }
in some scope variable then do use that inside your interpolation directive expression, that will simplify your escaping more better.
Markup
<div ng-init="maleFilter = { GENDER: 'male' }">
<input ng-attr-placeholder="{{ 'PLURAL' | translate: maleFilter : 'messageformat' }}">
<div>
Hope this could help you, Thanks.
Upvotes: 4
Reputation: 670
For future reference. These Angular Translate docs were confusing to me.
The format that works is:
placeholder="{{ 'PLURAL' | translate:{gender:'male'}:'messageformat' }}"
Upvotes: 1