2015-11-28 63 views
5

HTML內容,我有以下的模板:呈現離子

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

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

的問題是, 'post.contenido' 具有HTML,我想按照它應該顯示,但它只顯示HTML標籤和文本。

我能做些什麼來呈現這樣的內容?

親切的問候。

+0

您可以嘗試使用ion-view標籤並向其中注入html模板。 – Vandervidi

+0

無法弄清楚你的意思。任何例子? – Apalabrados

+0

好吧,看了一下後,忽略我的第一條評論。你有沒有嘗試過這樣的事情? http://stackoverflow.com/questions/19415394/with-ng-bind-html-unsafe-removed-how-do-i-inject-html – Vandervidi

回答

3

假設你有一個範圍變量,其中的html!

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

你應該能夠輸出它作爲這樣

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

..in你的情況應該是這樣的

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

這是疏遠的,但沒有在DIV內顯示。 – Apalabrados

+2

已使用指令'ng-bind-html'而不是'ng-bind-html-unsafe'解決。 – Apalabrados

3

我想你應該改變你的代碼:
<div class="item item-text-wrap" [innerHTML]="post.contenido"> </div>

1

適合我而不危險.. 所以解決方案是

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