繁体   English   中英

如何在角度4中使用具有ng-content(带有select标签)的ng-container

[英]How to use ng-container with ng-content (with select tag) in angular 4

如何将ng-container与具有select标签的ng-content结合使用。

<div class="container">
  <div id="first">
    <ng-container *ngTemplateOutlet="widgetContent"></ng-container>
  <div>
  <div id="second">
    <ng-container *ngTemplateOutlet="widgetContent"></ng-container>
  </div>
</div>

<ng-content #widgetContent select="side-widget, [sidewidget]"></ng-content>

尝试这个

<div class="container">
   <div id="first">
      <ng-container [ngTemplateOutlet]="widgetContent"></ng-container>
   <div>
   <div id="second">
      <ng-container [ngTemplateOutlet]="widgetContent"></ng-container>
   </div>
</div>

<ng-template  #widgetContent>
   <ng-content></ng-content>
</ng-template>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM