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