Why is projectableNodes an any[][]?

后端 未结 1 1896
闹比i
闹比i 2021-01-19 04:14

I\'ve played around with

ViewContainerRef.createComponent

and I\'m wondering why the parameter projectableNodes is an any[][]. Unfortunatelly, this parameter

1条回答
  •  挽巷
    挽巷 (楼主)
    2021-01-19 04:24

    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:

    
    

    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')
      ]
    ]);
    

    Plunker Example

    0 讨论(0)
提交回复
热议问题