当我使用角度的指令时,我得到了这个错误。为什么角度指令只能有一个根元素
Error: [$compile:tplrt] Template for directive 'header' must have exactly one root element. /apps/dhe.techForm/views/directives/header.html
http://errors.angularjs.org/1.4.8/$compile/tplrt?p0=header&p1=%2Fapps%2Fdhe.techForm%2Fviews%2Fdirectives%2Fheader.html
at angular.js:68
at angular.js:8512
at processQueue (angular.js:14792)
at angular.js:14808
at Scope.$eval (angular.js:16052)
at Scope.$digest (angular.js:15870)
at Scope.$apply (angular.js:16160)
at done (angular.js:10589)
at completeRequest (angular.js:10787)
at XMLHttpRequest.requestLoaded (angular.js:10728)
所以,如果我们关注到自己指令的HTML,将抛出角度误差
<div>
</div>
<div>
</div>
像下面的指令的HTML是好的。
<section>
<div>
</div>
<div>
</div>
</section>
为什么角度指令只能有一个根元素?
这是绝对的罚款。那必须是这样。使用/将其包装在一个元素中会出现什么问题? – Jai
也许阅读官方文档有助于:https://docs.angularjs.org/error/$compile/tplrt – Chanthu