2

I have a PHP web app with AngularJS front end. Some of our assets are SVG format which we insert dynamically using directives.

<div ng-bind-html="block.arrow_svg | unsafe"></div>

In the code above, block.arrow_svg is a string containing SVG code: '<svg>...</svg>' and theunsafe` Angular filter is just a shortcut for preventing escaping of markup.

This works fine normally, but apparently Android 4.2 doesn't play nicely with inline SVG via javascript. I don't fully understand that limitation, but I'm fairly confident it is the explanation for why the assets aren't appearing on Android 4.2 devices. If I hardcode the same inline SVG code into the static page (outside the Angular template) it appears normally on Android 4.2.

Does anyone know of a workaround to allow my inline SVG to work dynamically via javascript/angular?

emersonthis
  • 32,822
  • 59
  • 210
  • 375
  • @Julien for some reason it's not appearing. Not sure why... – emersonthis Apr 23 '15 at 16:54
  • These questions might help you: [SVG in the Android Browser](http://stackoverflow.com/questions/8125829/svg-in-the-android-browser) and [Using javascript to render svg in android](http://stackoverflow.com/questions/13229091/using-javascript-to-render-svg-in-android) – Julien Apr 24 '15 at 05:47
  • @Julien that answer is about JavaScript in the img tag... But I'm not doing that. – emersonthis Apr 24 '15 at 11:13

0 Answers0