-
Notifications
You must be signed in to change notification settings - Fork 27.4k
docs ($compile): add error documentation for noslot error in $compile #15828
Changes from 1 commit
29b3216
b5fd53f
62152ce
074bd67
e16801c
ceb1509
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
@ngdoc error | ||
@name $compile:noslot | ||
@fullName No matching slot in parent directive | ||
@description | ||
|
||
This error occurs when declaring a specific slot in a ng-transclude which does not map to the transclude property of the directive. | ||
|
||
```js | ||
// In this example the template has a declared slot missing from the transclude definition. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you please move the introductory description out of the code block and put it before the code block? Also for the working example |
||
// This example will generate a no slot error. | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. no slot => noslot |
||
var componentConfig = { | ||
template: '<div style="border: 1px solid black;">' + | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove the styles, they are unnecessary |
||
'<div ng-transclude="slotProvided"></div>' + | ||
'<div ng-transclude="noSlotProvided"></div>' + | ||
'</div>', | ||
transclude: { | ||
// The key value pairs here are considered "slots" that are provided for components to slot into. | ||
slotProvided: 'slottedComponent', // mandatory transclusion, | ||
optionalSlot: '?optionalComponent', // optional transclusion | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove the optional transclusion (also from the template), as they are not the focus of the error |
||
// there is no slot provided for the transclude 'noSlotProvided' declared in the above template | ||
} | ||
}; | ||
|
||
angular | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please remove the component registration, it's unnecessary |
||
.module('doc') | ||
.component('myComponent', componentConfig) | ||
|
||
``` | ||
|
||
```js | ||
\\ if we the following change we will no longer get no slot error. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If we make ... |
||
var componentConfig = { | ||
template: '<div style="border: 1px solid black;">' + | ||
'<div ng-transclude="slotProvided"></div>' + | ||
'<div ng-transclude="noSlotProvided"></div>' + | ||
'</div>', | ||
transclude: { | ||
slotProvided: 'slottedComponent', // mandatory transclusion, | ||
optionalSlot: '?optionalComponent', // optional transclusion, | ||
noSlotProvided: 'otherComponent' // now it is declared and the error should cease | ||
} | ||
}; | ||
|
||
``` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"Which does not map to a specific slot defined in the transclude property of the directive"