AngularJS: 'Template for directive must have exactly one root element' when using 'th' tag in directive template

后端 未结 12 1200
梦如初夏
梦如初夏 2020-12-30 19:50

I\'m trying to implement custom sortBy directive in order to make columns in html table sortable.

HTML:


   
            


        
12条回答
  •  一向
    一向 (楼主)
    2020-12-30 20:44

    I know this is old, but there is another solution. I encountered this issue also, and tried all the above solutions with no luck.

    turns out, for some weird reason, that this error is thrown also in case there is a typo in the 'templateUrl' - if angular can't find the html file by the given path - you get the same 'must have exactly one root element' error.

    so - fixing the templateUrl fixed the error for me.

    hope this helps anyone in the future.

提交回复
热议问题