Template must have exactly one root element with custom directive replace: true

前端 未结 4 1902
醉酒成梦
醉酒成梦 2021-02-01 09:35

I am having issues with a custom directive with replace: true,

http://jsbin.com/OtARocO/2/edit

As far as I can tell, I do only have one root element, my , what i

4条回答
  •  爱一瞬间的悲伤
    2021-02-01 09:56

    Seems to be a known bug of AngularJs.

    What you could do is to change the restriction to attribute instead of element, remove the tbody from the template and use a in your html code.

    Basically:

    Your template becomes:

    {{ item.name }}
    row2
    

    Your directive:

    return {
      restrict: 'A',
      templateUrl: 'lineItem.html',
      link: function(scope, element, attrs) {
    
      }
    };
    

    And your HTML :

提交回复
热议问题