【问题标题】:How To Put HTMLElement Inside Component Like Angular Material does如何像 Angular Material 一样将 HTMLElement 放入组件中
【发布时间】:2018-12-07 05:58:09
【问题描述】:

在 AngularMaterial 中,我看到了这样的代码。

<form class="example-form">
  <mat-form-field class="example-full-width">
    <input matInput placeholder="Favorite food" value="Sushi">
  </mat-form-field>
</form>

&lt;mat-form-field&gt; 组件内部有&lt;input&gt; 元素。

通常,当我在组件中编写元素时,它会被忽略。

我该怎么做。

【问题讨论】:

标签: angular


【解决方案1】:

使用&lt;ng-content&gt;&lt;/ng-content&gt; 插入元素。

https://medium.com/claritydesignsystem/ng-content-the-hidden-docs-96a29d70d11b

【讨论】:

    猜你喜欢
    • 2021-12-28
    • 2021-01-27
    • 2019-01-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-10-22
    • 2021-03-31
    相关资源
    最近更新 更多