I've played around with
ViewContainerRef.createComponent
and I'm wondering why the parameter projectableNodes is an any[][]. Unfortunatelly, this parameter hasn't been documented so far.
What to pass within this 2D-Array?
Wishes, Manfred
As we can have several ng-content we can pass several 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> So when we're creating component dynamically we can inject one and more nodes for each of 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') ] ]);