andrey andrey - 1 month ago 10
AngularJS Question

Angular Variables inside SVG

Error: Invalid value for <text> attribute x="{{xForLabels.text}}"
angular.js:2390 Error: Invalid value for <text> attribute x="{{xForLabels.textNumber}}"
angular.js:2390 Error: Invalid value for <circle> attribute cx="{{xForLabels.circle}}"
angular.js:2390 Error: Invalid value for <text> attribute x="{{xForLabels.text}}"
angular.js:2390 Error: Invalid value for <text> attribute x="{{xForLabels.textNumber}}"


I use angular scope variables for attributes inside svg, everything works as i expect, but in console i get this errors. how to get rid of them? thank you.

Answer

I think you should try ng-attr-x="{{xForLabels.text}}"

ref: https://docs.angularjs.org/guide/interpolation#-ngattr-for-binding-to-arbitrary-attributes

Comments