( defaultComponent: Type<T>, slotName?: string, )
| 275 | * ``` |
| 276 | */ |
| 277 | export function createSlotRenderer<T>( |
| 278 | defaultComponent: Type<T>, |
| 279 | slotName?: string, |
| 280 | ) { |
| 281 | // Get config in the injection context when the renderer is created |
| 282 | const config = slotName ? getSlotConfig() : null; |
| 283 | |
| 284 | return ( |
| 285 | viewContainer: ViewContainerRef, |
| 286 | slot?: SlotValue<T>, |
| 287 | props?: Partial<T>, |
| 288 | outputs?: Record<string, (event: any) => void>, |
| 289 | ) => { |
| 290 | // Check DI for overrides if slot name provided |
| 291 | if (slotName && !slot && config) { |
| 292 | const entry = config.get(slotName); |
| 293 | if (entry) { |
| 294 | if (entry.component) slot = entry.component; |
| 295 | else if (entry.template) slot = entry.template; |
| 296 | } |
| 297 | } |
| 298 | |
| 299 | return renderSlot(viewContainer, { |
| 300 | slot, |
| 301 | defaultComponent, |
| 302 | props, |
| 303 | outputs, |
| 304 | }); |
| 305 | }; |
| 306 | } |
no test coverage detected
searching dependent graphs…