Multiple ng-content

后端 未结 4 456
庸人自扰
庸人自扰 2020-12-12 16:44

I am trying to build a custom component using multiple ng-content in Angular 6, but this is not working and I have no idea why.

This is my component code

4条回答
  •  盖世英雄少女心
    2020-12-12 17:35

    1. You could add dummy attributes header and body as opposed to template references (#header, #body).
    2. And transclude using ng-content with select attribute like select="[header]".

    app.comp.html

    
        
    This should be rendered in header selection of ng-content
    This should be rendered in body selection of ng-content

    child.comp.html

    DEMO

提交回复
热议问题