Skip to content

Commit 4175377

Browse files
mheveryIgorMinar
authored andcommitted
docs(compile/tplrt): description for compile/tplrt error
Closes angular#3459
1 parent dbd703a commit 4175377

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

docs/content/error/compile/tplrt.ngdoc

+26
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,29 @@
22
@name $compile:tplrt
33
@fullName Invalid Template Root
44
@description
5+
6+
When a directive is declared with `template` (or `templateUrl`) and `replace` mode on, the template must have exactly one root element.
7+
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.
8+
9+
10+
For example a directive with definition:
11+
```
12+
myModule.directive('myDirective', function factory() {
13+
return {
14+
...
15+
replace: true,
16+
templateUrl: 'someUrl'
17+
...
18+
}
19+
});
20+
```
21+
22+
And a template provided at URL `someUrl`. The template must be an html fragment that has only a single root element, like the `div` element in this template:
23+
```
24+
<div><b>Hello</b> World!</div>
25+
```
26+
27+
An an invalid template to be used with this directive is one that defines multiple root nodes or elements. For example:
28+
```
29+
<b>Hello</b> World!
30+
```

0 commit comments

Comments
 (0)