BenYsil
BenYsil

Reputation: 147

Ngx-translate Angular Variable value problem

I try to get value from a component variable to translate with lazyloading

<label class="text-white" >{{ 'profil.city' | translate }} &nbsp;</label>
<input class="text-white bg-transparent" value="{{user.town}}">   /* Works*/

<label class="text-white" >{{ 'profil.sex' | translate }} &nbsp;</label>
<input class="text-white bg-transparent" value="{{ '{{user.sex}}' | translate}}"> /* Don't Works */ 

I get error with the

 {{ '{{user.sex}}' | translate}}"

I Just want to get user.sex value which is a entry in the language.json to translate.

How can I get the value to translate it Correctly ?

Thank you all !

Upvotes: 1

Views: 354

Answers (3)

Nenad Radak
Nenad Radak

Reputation: 3678

Use it like this:

 {{'user.sex' | translate }}

Upvotes: 1

Bienfait Rukundo
Bienfait Rukundo

Reputation: 51

just remove the semi colon do like this :value="{{user.sex | translate}}"

Upvotes: 0

Qortex
Qortex

Reputation: 7456

You can go back to normal evaluation instead of template expansion:

[value]="'user.sex' | translate"

or also this will work

value={{ 'user.sex' | translate }}

Upvotes: 0

Related Questions