2015-11-04 54 views
4

我的應用程序使用Angularjs和ionic進行構建,使用cordova作爲混合移動應用程序,當嘗試渲染從後端接收的svg內容時,應用程序無法呈現預期圖。如何在離子內容中呈現svg

這是我的代碼看起來像

<ion-tab title="Diagram" icon-on="mcfly">   
     <ion-view> 
      <ion-content class="padding" ng-class="{'has-loading': header.isLoading}"> 
       <h4>System Diagram</h4>     
        {{diagram}} 
     </ion-content> 
    </ion-view> 
</ion-tab> 

但我看到的是SVG數據,而不是形象,我錯過任何聲明或任何東西嗎?

感謝

+0

彼此的答案,我發現是http://stackoverflow.com/questions/9381926/angularjs-insert-html-into-view – Amit

回答

5

你需要把它放在圖像標籤,就像這樣:

<img class="title-image" src="path to your diagram" width="xxx" height="xxx" /> 

請檢查該plunker顯示SVG

+0

讓我嘗試一下,但是我不能使用svg內容作爲xml, 在$ scope內部傳遞,並在離子內容中渲染? – Amit

+0

這工作正常,謝謝你。 不知怎的,渲染後的圖像太小了,雖然我把寬度和高度都設爲100%,它可能會從那裏拉出來? – Amit

+0

不確定,請嘗試使用px而不是%來查看它是否有所作爲。 – macrog