Including SVG template in Angularjs directive

后端 未结 5 1157
隐瞒了意图╮
隐瞒了意图╮ 2020-11-30 06:21
5条回答
  •  一生所求
    2020-11-30 06:45

    Currently SVG tags don't support dynamic addition of tags, at least in Chrome. It doesn't even display the new rect, nor would it even if you just added it directly with the DOM or JQuery.append(). Have a look at just trying to do it with JQuery

    // this doesn't even work right. Slightly different error than yours.
    $(function() {
        $('svg').append('');
    });
    

    My guess is you're going to see some really crazy behavior no matter what you do in this manner. It seems like it's an issue with the browser, and not so much Angular. I'd recommend reporting it to the Chromium project.

    EDIT:

    It looks like it might work if you add it via the DOM 100% programmatically: How to make Chrome redraw SVG dynamically added content?

提交回复
热议问题