Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Angular 4 how to inject svg

Tags:

angular

svg

I have always used svg in tags or as background-image. Having recently followed : https://css-tricks.com/using-svg/ I would like to inject my svg directly. Has Angular4 any features allowing so ?

like image 381
Scipion Avatar asked Nov 07 '22 18:11

Scipion


1 Answers

Updated answer:

As @osama-felfel pointed out, the library indeed doesn't inject during build phase, but instead inject it as the component is loaded. I think this is even better, as it allow for the SVG to be downloaded in parallel.

For the bundle size comment by @user776686, it is analyzed and contested here.


Original answer:

I guess you solved your problem, but I will post this here if anybody stumbles upon this. I used this library. It allows the svg to be injected during the build phase, so your css rules are applied.

like image 124
joao Beno Avatar answered Nov 14 '22 22:11

joao Beno