简体   繁体   中英

translate attribute values with ngx-translate angular

I am trying to use ngx-translate for attribute values like p-messages text, p-column header, p-tabPanel header

<p-message text="text"></p-message>

<p-column header="text"></p-column>

<p-tabPanel header="text">

I tried the following but it doesn't work:

<p-tabPanel header="'key' | translate">

<p-tabPanel header="{{'key' | translate}}">

<p-tabPanel [attr.header]="'key' | translate">

Is there any way to use ngx-translate for these?

From this github issue

<img src="image.jpg" [attr.alt]="'key' | translate"> or like this:
<input placeholder="{{'key' | translate}}">

The following solution worked:

 <p-tabPanel header="{{'key' | translate}}">

But be very careful to import TranslateModule in the needed module.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM