Z
Z
zlodiak2018-05-23 00:22:44
Angular
zlodiak, 2018-05-23 00:22:44

How to embed svg using Renderer2?

How to embed an svg component into the template using Renderer2 in Angular?

The problem is that the svg embedded in this way is not displayed in the browser, and is not visible at all in the styles inspector: here is a demo https://stackblitz.com/edit/angular-ccmzfx

At the same time, the same svg inserted in the template hands, displayed without problems. This can be seen in the same example.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
0
0xD34F, 2018-05-23
@zlodiak

When creating SVG elements, you must specify a namespace. That is, replace with Well and, respectively , with
this.renderer.createElement('circle', 'svg');

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question