Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

542
Visualizações
typescript new line character in string is not working

I'm using a directive to show a tooltip text:

<i class="fas fa-info-circle" [nz-tooltip]='infoBulleContent'  nzTooltipPlacement='topRight'></i>

in ts code, this.infoBulleContent = 'Some text \n some text'; but the \n is not working, i used also the br tag, same result!

any help please

over 4 years ago · Santiago Trujillo
2 Respostas
Responde à pergunta

0

This won't work, alas. As you can see in the source of this tooltip component, the title that you give is not parsed but directly included as a string in the template.

Having said that, what you probably want here is to pass a TemplateRef, which allows you to include multiple lines, but also styling (which is preferable over using manual br-line breaks). E.g.

    <!-- Element that should have a tooltip -->
    <button nz-tooltip [nzTooltipTitle]="titleTemplate">Test</button>

    <!-- Contents of tooltip -->
    <ng-template #titleTemplate>
      <p style="font-size: 25px">Your <br> tooltip</p>
    </ng-template>
over 4 years ago · Santiago Trujillo Relatório

0

\n does not cause a line break in html. You'll need to use a <br/> or wrap your text in a block element.

this.Values += this.Id + ',' + this.status + '<br/>';

or

this.Values += '<div>' + this.Id + ',' + this.status + '</div>';
over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda