How to render svg inside ion-content

Amit picture Amit · Nov 4, 2015 · Viewed 14.6k times · Source

My application is built using Angularjs and ionic, using cordova for hybrid mobile application, when trying to render svg content received from backend, application is unable to render expected diagram.

This is how my code looks like

<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>

But what I see is svg data instead of image, am I missing any declaration or any thing ?

Thanks

Answer

macrog picture macrog · Nov 4, 2015

You need to put it in image tag, like this:

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

please check this plunker displaying svg