小编adm*_*r86的帖子

有没有办法获取打字稿对象的所有必需属性

有没有一种方法可以获取打字稿界面或对象的所有必需属性。类似Object.getOwnPropertyDescriptors(myObject)keyof T带有信息属性的东西是必需的/可选的

reflection typescript

1
推荐指数
2
解决办法
695
查看次数

ng-template 内的 ng-content 仅出现在一个 ng-container 中

我正在创建一个翻转面板。该面板由三部分组成。

  • 面板工具栏
  • 前面板
  • 面板背面

工具栏有一个固定部分,即翻转按钮。

在我的 Flip-panel.component 中,我有一个工具栏的 ng-template,因为工具栏应该显示在两侧并且应该是相同的。但我还在该模板中使用 ng-content 来获取工具栏的用户定义项目。

我的翻转面板组件:

<div class="flip-panel">

  <div class="front-container">
    <ng-container [ngTemplateOutlet]="headerTemplate"></ng-container>
    <ng-content select="panel-front"></ng-content>
  </div>

  <div class="back-container">
    <ng-container [ngTemplateOutlet]="headerTemplate"></ng-container>
    <ng-content select="panel-back"></ng-content>
  </div>

</div>

<!-- template used in both container front and back -->
<ng-template #headerTemplate>
  <div class="flip-panel-header">
    <span>
      <ng-content select="panel-tool-bar"></ng-content>
    </span>
    <span class="flip-button" aria-hidden="true" (click)="toggle()">[Flip]</span>
  </div>
</ng-template>
Run Code Online (Sandbox Code Playgroud)

我遇到的问题是,工具栏中用户定义的项目(从面板工具栏中选择的内容)仅显示在背面内容上。

这是一个完整的示例: https://stackblitz.com/edit/angular-fsnww2 ?file=src%2Fapp%2Fapp.component.html

ng-template angular ng-container ng-content

1
推荐指数
1
解决办法
5583
查看次数