Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Commit d7e888b

Browse files
xavhanpetebacondarwin
authored andcommitted
docs(error/$compile): add reqslot error description
Explains what could generate a `reqslot` error. Closes #14618
1 parent 491b4af commit d7e888b

File tree

1 file changed

+47
-0
lines changed

1 file changed

+47
-0
lines changed
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
@ngdoc error
2+
@name $compile:reqslot
3+
@fullName Required transclusion slot
4+
@description
5+
6+
This error occurs when a directive or component try to transclude a slot that is not provided.
7+
8+
Transcluded elements must contain something. This error could happen when you try to transclude a self closing tag element.
9+
Also you can make a transclusion slot optional with a `?` prefix.
10+
11+
```js
12+
// In this example the <my-component> must have an <important-component> inside to transclude it.
13+
// If not, a reqslot error will be generated.
14+
15+
var componentConfig = {
16+
template: 'path/to/template.html',
17+
tranclude: {
18+
importantSlot: 'importantComponent', // mandatory transclusion
19+
optionalSlot: '?optionalComponent', // optional transclusion
20+
}
21+
};
22+
23+
angular
24+
.module('doc')
25+
.component('myComponent', componentConfig)
26+
27+
```
28+
29+
```html
30+
<!-- Will not work because <important-component> is missing -->
31+
<my-component>
32+
</my-component>
33+
34+
<my-component>
35+
<optional-component></optional-component>
36+
</my-component>
37+
38+
<!-- Will work -->
39+
<my-component>
40+
<important-component></important-component>
41+
</my-component>
42+
43+
<my-component>
44+
<optional-component></optional-component>
45+
<important-component></important-component>
46+
</my-component>
47+
```

0 commit comments

Comments
 (0)