arkon / ng-inline-svg

[Inactive] Angular directive for inserting an SVG file inline within an element.
https://echeung.me/ng-inline-svg/
MIT License
210 stars 88 forks source link

Make ng-inline-svg working with server-side rendering. #45

Closed renestalder closed 6 years ago

renestalder commented 7 years ago

I noticed, that when rendering an Angular page server-side, the svgs will not show up.

Is there a trick for getting that working or is it just not supported (yet)?

renestalder commented 7 years ago

Oh well, I just saw this:

if (!this._isBrowser) { return; }

So I reformulate my issue.

renestalder commented 7 years ago

I might be able making a pull request for this. I have to dig a bit deeper in your code, but normally it shouldn't be a problem adding the svg element to DOM server-side.

arkon commented 7 years ago

A PR would be appreciated! I don't have much experience with SSR.

arkon commented 6 years ago

I think this will be solved with Renderer3 when that rolls around.

renestalder commented 6 years ago

I'll anyway have to check on this until the middle of the month since the web app I maintain will go full server-side. So I'm going to check and might push that long promised adaption for server-side. (Since conditions in your code will have to be adapted with or without renderer3)

renestalder commented 6 years ago

I started with this, but stuck at the point where the svg file is retrieved on server-side. On client-side with the absolute URL this is a no-brainer. On server side, I first tried by setting baseURL manually, then by using relative urls instead of absolute urls. The http get call never comes back.

I have to research more in depth how to retrieve files on server-side. Possibly also only a configuration problem.

renestalder commented 6 years ago

So, I have the PR ready and I tested it server-side and client-side in a big, productive project. But still, you might to want to test the client-side functions again. I'm not sure we use all the features in our application.

arkon commented 6 years ago

Published in v6.1.0. Thanks @renestalder !

Avcajaraville commented 5 years ago

Hi ! Just followed all the steps on the README.md and still can‘t figure how to make it work.

In my case, no svg are output when using universal.

Thanks !

Avcajaraville commented 3 years ago

Does anyone know how to solve this issue? Its being a while and I'm still not able to make it work with server-side rendering :(