【问题标题】:show what's between the component calling elements in angular以角度显示组件调用元素之间的内容
【发布时间】:2021-02-07 04:24:45
【问题描述】:

我需要配置一个组件来显示他的调用元素中的内容。我该怎么做?

这是我的代码

<app-card>
    <h1>test</h1>
    ...
</app-card>

我想让 app-card 组件把他里面的所有 html 代码都拿出来并显示出来

【问题讨论】:

    标签: angular typescript


    【解决方案1】:

    类似的东西应该可以解决问题。

    应用卡组件:

    @Component({
      selector: 'app-card',
      template: '<ng-content></ng-content>'
    })
    
    export class CardComponent {
    
    }
    

    【讨论】:

      猜你喜欢
      • 2021-01-04
      • 2021-08-26
      • 1970-01-01
      • 1970-01-01
      • 2016-08-19
      • 2021-02-03
      • 1970-01-01
      • 2021-08-24
      • 2022-01-12
      相关资源
      最近更新 更多