Apalabrados Apalabrados - 2 months ago 42
AngularJS Question

Render HTML content in Ionic

I have the following template:

<ion-view view-title="Playlist">

<div class="list list-inset">
<div class="item item-divider item-text-wrap">
<div class="item">
<img src="{{post.image}}" width="100%" />
<div class="item item-divider" style="font-size:14px;font-weight:normal;text-align:right">
{{post.fecha}} - By: {{post.autor}}
<div class="item item-text-wrap">
{{ post.contenido }}

The question is that 'post.contenido' has HTML that I wish to be displayed as it should but it only show the HTML tags and text.

What can I do to render such content?

Kind regards.


Let's say you a scope variable with html in it !

$scope.someHTML = "<h1>Big Nice Title here</h1>";

You should be ebale to output it as so

<div ng-bind-html-unsafe="someHTML"></div>

..in your case it should be like this

<div class="item item-text-wrap" ng-bind-html-unsafe="post.contenido"></div>