0

Im trying to show a text in the screen using:

{{content.lore}}

so far ok, but my text is formatted like this:

"...<br><br>Essa criação poderosa - forjada à imagem de uma gárgula - o manteve<br><br> seguro em suas jornadas, permitindo que ele desempenhasse seu importante trabalho sem medo de retaliações daqueles hostis à sua terra natal.<br><br> Isso é, até despertar a ira do Alto Comando Noxiano com suas sentinelas.<br><br>...".

These <br> are showed in the text and i want to delete it. Using

content.lore.replace("<br>", "");

the text don't change. How can i replace these <br>?

Bruno Brito
  • 345
  • 4
  • 17
  • You might want to use `ng-bind-html` - here is the documentation for that. https://docs.angularjs.org/api/ng/service/$sce - Angular by default escapes all HTML, so you have to either mark the source as trusted, or disable this in angular. – Alex Szabo Feb 28 '16 at 20:58
  • Also, I think this answer might be helpful: http://stackoverflow.com/questions/18340872/how-do-you-use-sce-trustashtmlstring-to-replicate-ng-bind-html-unsafe-in-angu – Alex Szabo Feb 28 '16 at 20:58

1 Answers1

1

Could use a filter that converts html to text if you want to remove the <br>

app.filter('htmlToText', function(){
  return function(html){        
     return angular.element('<div>').append(html || '').text();
  };
});

View

{{content.lore | htmlToText}}
charlietfl
  • 170,828
  • 13
  • 121
  • 150