Reputation: 313
I'm inserting an SVG through AngularJS:
<embed embed-src="{{sportImage}}" type="image/svg+xml" class="svg sport-image" width="470" height="418" />
But I can't change the fill of the svg or path through CSS or JS. I'm guessing this is because the SVG is loaded after the API returns its results.
Any tips?
Upvotes: 3
Views: 4259
Reputation: 124269
You need to make the change after the onload of the <embed>
has occurred.
<embed embed-src="{{sportImage}}" type="image/svg+xml" class="svg sport-image" width="470" height="418" onload="f()" id="something" />
<script>
function f() {
var svg = document.getElementById('something');
var element = svg.getSVGDocument().getElementById("an-id-in-the-embedding");
element.setAttribute("fill", "some-colour");
}
</script>
Upvotes: 3