In my app I generate svg sprite with gulp-svgstore
and then I loaded in the index.html in angular2-cli app with ajax call
<script>
var ajax = new XMLHttpRequest();
ajax.open("GET", "./assets/images/icon/sprite.svg", true);
ajax.send();
ajax.onload = function() {
var div = document.createElement("div");
div.setAttribute("class", "sprites");
div.innerHTML = ajax.responseText;
document.body.insertBefore(div, document.body.childNodes[0]);
};
</script>
and then I wrote a component for svg icon :
import { Component, Input } from '@angular/core';
@Component({
selector: 'icon',
template: `<svg class="icon" [style.width.px]="size"
[style.height.px]="size"
[style.fill]="fill"
[ngClass]="class">
<use [attr.xlink:href]="'#' + name"></use></svg>`
})
export class IconComponent {
@Input() name: string;
@Input() size: any;
@Input() fill: any;
@Input() class: any;
@Input() marginLeft: any;
constructor() { }
}
and this work just fine in Chrome or Safari browser, but in Firefox it doesn't show up without any error or warning! when I checked network tab in Firefox look like a sprites file loaded but still doesn't show up!
How can I fix this issue? why Firefox act like that?
Thanks a lot.