Scipion
Scipion

Reputation: 11888

Angular 4 how to inject 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 ?

Upvotes: 5

Views: 8329

Answers (1)

Maxinne
Maxinne

Reputation: 1693

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.

Upvotes: 1

Related Questions