24 lines
1.7 KiB
HTML
Executable file
24 lines
1.7 KiB
HTML
Executable file
<a href="http://github.com/angular/angular.js/edit/master/docs/content/error/compile/tplrt.ngdoc" class="improve-docs btn btn-primary"><i class="icon-edit"> </i> Improve this doc</a><h1><code ng:non-bindable="">Invalid Template Root</code>
|
|
<div><span class="hint">error in component <code ng:non-bindable="">$compile</code>
|
|
</span>
|
|
</div>
|
|
</h1>
|
|
<div><pre class="minerr-errmsg" error-display="Template for directive '{0}' must have exactly one root element. {1}">Template for directive '{0}' must have exactly one root element. {1}</pre>
|
|
<h2 id="Description">Description</h2>
|
|
<div class="description"><div class="-compile-page -compile-tplrt-page"><p>When a directive is declared with <code>template</code> (or <code>templateUrl</code>) and <code>replace</code> mode on, the template must have exactly one root element.
|
|
Otherwise the replacement operation would result in a single element being replaced with multiple elements or nodes, which is unsupported and not commonly needed in practice.</p>
|
|
<p>For example a directive with definition:</p>
|
|
<pre><code>myModule.directive('myDirective', function factory() {
|
|
return {
|
|
...
|
|
replace: true,
|
|
templateUrl: 'someUrl'
|
|
...
|
|
}
|
|
});</code></pre>
|
|
<p>And a template provided at URL <code>someUrl</code>. The template must be an html fragment that has only a single root element, like the <code>div</code> element in this template:</p>
|
|
<pre><code><div><b>Hello</b> World!</div></code></pre>
|
|
<p>An an invalid template to be used with this directive is one that defines multiple root nodes or elements. For example:</p>
|
|
<pre><code><b>Hello</b> World!</code></pre>
|
|
</div></div>
|
|
</div>
|