angular pass interpolation as function parameter
I have a function to display a tooltip. This function accepts string param. I want to pass the translated string to thi开发者_JS百科s function. But when I pass the value is not parsed and displayed as text.
'<input type="text" class="form-control" placeholder="{{'placeholder_val'|translate}}" ngModel name="name"
[ngbPopover]="tipContent" popoverClass="help-tips" [autoClose]="'outside'" triggers="manual"
#p1="ngbPopover"
(click)="toggleTips(p1, '{{`tootltip_val`|translate}}')">'
Did you mean:
(click)="toggleTips(p1, {{'tootltip_val' | translate}})"
instead of
(click)="toggleTips(p1, '{{`tootltip_val`|translate}}')">
<input
type="text"
class="form-control"
placeholder="{{'placeholder_val' | translate}}"
ngModel
name="name"
[ngbPopover]="tipContent"
popoverClass="help-tips"
[autoClose]="'outside'"
triggers="manual"
#p1="ngbPopover"
(click)="toggleTips(p1, {{'tootltip_val' | translate}})" />
Note also that your variable is named tootltip_val
instead of tooltip_val
, maybe that is also the source of error?
Lastly:
- If
tootltip_val
is a static string that is mapped to your translation system, then{{'tootltip_val' | translate}}
is fine. - If
tootltip_val
is a dynamic variable set in your.ts
file, you should instead be using{{tootltip_val | translate}}
精彩评论