3

I'm using Angular-translate and I am trying to load a text from JSON with breakline, but the html is not recognizing.

JSON:

"ABOUT": {
    "headline":"Every day\n every moment",
    "span": "Be Like"
}

ANGULARJS:

.config(function($translateProvider) {

// Sanitize
$translateProvider.useSanitizeValueStrategy('escaped');

// Load  JSON
$translateProvider.useStaticFilesLoader({
    prefix: '/app/languages/app-',
    suffix: '.json'
});
$translateProvider.preferredLanguage('en');

HTML:

        <h2> <span>{{ 'ABOUT.span' | translate }}</span>
        {{ 'ABOUT.headline' | translate }}
       ....

Is there some way to do that?

1 Answer 1

4

Use white-space:pre; in css so it would be like that in your html

<h2 style="white-space:pre;"> <span>{{ 'ABOUT.span' | translate }}</span>{{ 'ABOUT.headline' | translate }} </h2>

here is a plunker http://plnkr.co/edit/Bjs6LC9Z9Fy1v5ULqlVW?p=preview

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.