Replace innerHtml with CSS content SVG
I'm trying to replace innerHtml for injecting a svg with a css class + content, without success: https://stackblitz.com/edit/angular-1vdnfe2h?file=src%2Fapp%2Fapp.component.ts both the original innerHtml and the test replacement can be found here. What am I doing wrong?
7 Replies
why?
what exactly are you trying to do?
what is your goal?
I don't want to use innerHtml due to security reasons and instead add the svg via css property
why dont you use a background image?
or an <img> element?
Both createElement() and innerHTML are not normal Angular techniques. Angular has a template system for rendering elements. For conditional rendering, see this: https://v18.angular.dev/essentials/conditionals-and-loops
The whole point of using Angular, React, Vue, etc. is that they manage the UI for you without needing such DOM manipulation code.
This is an external library and it doesn't provide any method to customise the toolbar, I already asked Telerik Support and they recommended the css approach
Can I use svg with background image? What sets me off is that the svg has in its info the height and width parameters
This is my attempt with background image
Ok I was able to solve it with this solution: https://stackoverflow.com/a/21626701
scary but should work
you didnt encode the slashes and the :
otherwise, should work
I like the base64 version more, it's more readable
And seems to work better across browsers