I am completely new to AngularJS and I seem to be having some trouble understanding why Angular doesn't seem to play well with <svg>
elements. Whenever I attempt to activate SVG elements using Angular, console errors come up.
For example, within a directive, I have the following template:
<svg xmlns='http://www.w3.org/2000/svg' class='svgtime'>\
<path stroke='#fff' stroke-width='5' d='M {{radius+line_size}} 2.50000119262981 A {{radius+line_size-2.5}} {{radius+line_size-2.5}} 0 1 1 {{radius+line_size-0.1}} 2.500055466403296 Z' fill='transparent'></path>
<path fill='transparent' stroke='#9BC7F2' stroke-width='2' ng-attr-d='M 60 2 A 58 58 0 0 1 77.83716831288882 5.497827994417321'></path>
I've set the radius
variable within the directive scope, but this code just won't work. The console keeps pointing out that there is an invalid value for the d
attribute of the path element. I've even tried using ng-attr-d
as suggested in the official Angular directives documentation, but it didn't do the trick either. What's causing this issue? Could it be something related to how Angular replaces {{}} placeholders with actual values within SVG elements? Perhaps when Angular does its magic after rendering <svg>
, errors arise?
I'm aware of hacks like: How to prevent AngularJS from changing HTML attributes to lowercase. But then why doesn't ng-attr-*
work as expected?