put new line in string to translate

前端 未结 3 1781
小蘑菇
小蘑菇 2021-02-19 05:24

I\'m using ngx-translate.

How can I put a line break in a string to translate ?

In my template I have :

{{\'STRING_TO_TRANSLATE\' | translate}}
         


        
3条回答
  •  感动是毒
    2021-02-19 06:10

    It works! But instead of

    {{'STRING_TO_TRANSLATE' | translate}}
    

    You should do


    s
    should work just fine, but in other cases you may need some additional 'safe html pipe', i.e:

    import { Pipe, PipeTransform } from '@angular/core';
    import { DomSanitizer } from '@angular/platform-browser';
    
    @Pipe({name: 'mySafeHtmlPipe'})
    export class SafeHtmlPipe implements PipeTransform {
      constructor(private sanitizer: DomSanitizer) {
      }
    
      public transform(htmlContent) {
        return this.sanitizer.bypassSecurityTrustHtml(htmlContent);
      }
    }
    

提交回复
热议问题