Answer the question
In order to leave comments, you need to log in
How to set width of svg using variable?
I'm trying to set the width of an svg using the viewBox attribute. The result should be an svg that, when the window width changes, also changes its width.
The problem is that I'm using a variable whose value is set in the component:
<svg viewBox="0 0 100 bla">
<circle cx="50" cy="50" r="40" stroke="black" stroke-width="3" fill="red" />
Sorry, your browser does not support inline SVG.
</svg>
Template parse errors:
Can't bind to 'viewBox' since it isn't a known property of ':svg:svg'. ("
]viewBox="0 0 100 {{bla}}">
Answer the question
In order to leave comments, you need to log in
<svg [attr.viewBox]="'0 0 100 ' + bla">
<circle cx="50" cy="50" r="40" stroke="black" stroke-width="3" fill="red" />
Sorry, your browser does not support inline SVG.
</svg>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question