Why is projectableNodes any [] []?

I played with

ViewContainerRef.createComponent

and I'm wondering why the projectableNodes parameter is any [] []. Unfortunately, this parameter is not documented yet.

What do you need to go through in this two-dimensional array?

Wishes, Manfred

+3
source share
1 answer

Since we can have multiple ng-content , we can pass multiple array nodes for each of ng-content

Let's say we have the following dynamic component:

 <ng-content></ng-content> <div class="container"> <div class="sidebar"> <ng-content></ng-content> </div> <div class="content"> <ng-content></ng-content> </div> </div> 

Therefore, when we dynamically create a component, we can enter one and several nodes for each of the ng-content places:

 this.vcRef.createComponent(factory, this.vcRef.length, null, [ [document.createTextNode('Top ng-content - Header')], [ document.createTextNode('First ng-content'), document.createElement('br'), document.createTextNode('First ng-content second row') ], [ document.createTextNode('Second ng-content'), document.createElement('br'), document.createTextNode('Second ng-content second row') ] ]); 

Plunger example

+4
source

Source: https://habr.com/ru/post/1268397/


All Articles