是深的内容,在所有可能的选择?

问题描述 投票:2回答:1

假设我想transclude这样一个标记为NG-内容:

<div aaa>
  AAA
</div>
<div aaa bbb>
  BBB
</div>

为此,我可以使用选择(看起来像普通的CSS的):

<ng-content select="div[aaa]"></ng-content>
----- some other content here -----
<ng-content select="div[aaa][bbb]"></ng-content>

但是,如果我有这样的内容(我无法摆脱“部分”标签的):

<section>
  <div aaa>
    AAA
  </div>
  <div aaa bbb>
    BBB
  </div>
</section>

什么选择我可以用它来得到相同的结果?这并没有为我工作:

<ng-content select="section div[aaa]"></ng-content>
----- some other content here -----
<ng-content select="section div[aaa][bbb]"></ng-content>

无论是这样的:

<ng-content select="section>div[aaa]"></ng-content>
----- some other content here -----
<ng-content select="section>div[aaa][bbb]"></ng-content>

对此有什么解决办法?为什么选择不为CSS一个工作?这是设计?我找不到文件的原因所在......

这将有助于如果“节”的标签替换为“NG-模板”或“NG容器”?

angular angular2-template angular2-ngcontent ng-content
1个回答
0
投票

我不相信这是可能的NG-内容。

有你想要做什么的替代品,但他们更复杂一点。

我的首选方式做,这是使用角度CDK门户。欲了解更多信息,请参阅:

© www.soinside.com 2019 - 2024. All rights reserved.