簡體   English   中英

使用ng-content選擇基類

[英]Using ng-content to select base class

假設我有一個組件Parent ,內容項目Child組件如下。 在這種情況下, Child是受部件延伸一個抽象基類ChildAChildB 以下是在用戶模板中使用的示例:

<parent>
  <child-a></child-a> // or child-b
</parent>

Parent的模板中,我想使用<ng-content>來內容項目Child組件。 但是,我希望能夠使用<ng-content>並以某種方式選擇<child-a><child-b> ,例如:

<ng-content select="child-a | child-b"></ng-content>

有沒有辦法做到這一點?

您可以使用逗號分隔的列表執行此操作,如下所示:

<ng-content select="child-a,child-b"></ng-content>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM