3
I am consuming data from an angular api, the api is returning me the following value with HTML:
variavel = '<p>testo de retorno</p>';
When I do the view view type {{variable}} is interpreted all as string displaying HTML. I need to display only the text considering the HTML tags, that is, I cannot remove the HTML. You have to display only the text and interpret the HTML.
Does anyone know how I can do this using angular?
Have a look at ngBindHtml https://docs.angularjs.org/aping/directive/ngBindHtml. Angular treats HTML to prevent XSS attack.
– lfarroco
thanks man. I’m checking it now
– Miguel Batista
@Miguelbatist you might run into some errors (like $sce) when using
ng-bind-html
. This happens by the absence of the modulengSanitize
. I answered another user with this problem here: http://answall.com/questions/132005/problema-no-angular-1-5-rodando-com-arquivos-minificados– celsomtrindade
I managed to solve here. I will post the answer and I really came across this error regarding $sce
– Miguel Batista
@Celsomtrindade I managed to solve without ngSanitize. Only with the dependency of $sce.
– Miguel Batista