Pooja Potghan-Kadam
Pooja Potghan-Kadam

Reputation: 315

Unable to translate contents in span in AngularJS

I try to add translation for following line

<h3>List your property <span>for sale or rent</span></h3>

I have added translation for "List your property” and "for sale or rent" in my JSON file.But when I add translations it shows only "List your property” and "for sale or rent” text is not shown.

I'm using following code:

<h3 ng-show="lang == 'es'" 
    ng-click="changeLanguage('en')" 
    translate="LIST_YOUR_PROPERTY">
    <span ng-show="lang == 'es'" 
          ng-click="changeLanguage('en')" 
          translate="FOR_SALE_OR_RENT"></span>
</h3>

Upvotes: 2

Views: 1124

Answers (1)

lin
lin

Reputation: 18392

You have to use your translation keys like its shown in the ngTranslate documentation. Use the HTML Template binding for LIST_YOUR_PROPERTY so your value inside your <h3></h3> element doesnt get replaced by the translation string.

<h3>{{ 'LIST_YOUR_PROPERTY' | translate }}<span translate="FOR_SALE_OR_RENT"></span></h3>

Upvotes: 1

Related Questions