-1

I am migrating an application from Angular1 to Angular2, in which I used the svg.js library to draw an SVG. Some elements of the SVG contained "ng-click" directives, that I made the SVG library print to the final SVG.

That worked alright in Angular1, however, now the directive is called "(click)" and everything breaks. I traced the SVG sources and found that the following call

this.node.setAttribute(attr, value.toString())

results in the following error message:

VM22161:1 Uncaught DOMException: Failed to execute 'setAttribute' on 'Element': '(click)' is not a valid attribute name.(…)

Any ideas to solve that problem? Patching the SVG source would be ok for me, if there's no other way.

Jan B.
  • 6,030
  • 5
  • 32
  • 53
  • Can you please add more code. Hard to see what's going on with this small fragments. – Günter Zöchbauer May 12 '16 at 18:37
  • I'm sorry. I guess everything boils down to the fact, that the setAttribute() function does now allow attribute names to start with a bracket. If I am right, the node object is provided by the API of browser's engine, which makes it pretty complicated. – Jan B. May 13 '16 at 08:24
  • I found another solution for that issue. The binding syntax of Angular2 allows to use "on-click" instead of "(click)". – Jan B. May 13 '16 at 08:24
  • You can add that as an answer to your question. – Günter Zöchbauer May 13 '16 at 08:29

1 Answers1

0

A valid and quick workaround is to use the binding syntax of Angular2, that allows to use "on-click" instead of "(click)".

Jan B.
  • 6,030
  • 5
  • 32
  • 53