AngularJS - add HTML element to dom in directive without jQuery

前端 未结 4 1547
逝去的感伤
逝去的感伤 2021-01-31 02:35

I have an AngularJS directive in which I want to add a svg tag to the current element of the directive. Right now I do this with the help of jQuery

link: functio         


        
4条回答
  •  谎友^
    谎友^ (楼主)
    2021-01-31 03:15

    Why not to try simple (but powerful) html() method:

    iElement.html('');
    

    Or append as an alternative:

    iElement.append('');
    

    And , of course , more cleaner way:

     var svg = angular.element('');
     iElement.append(svg);
    

    Fiddle: http://jsfiddle.net/cherniv/AgGwK/

提交回复
热议问题