简体   繁体   English

如何将HTMLElement像Angular Material一样放在组件内部

[英]How To Put HTMLElement Inside Component Like Angular Material does

In AngularMaterial, I saw code like this. 在AngularMaterial中,我看到了这样的代码。

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

There are <input> element inside <mat-form-field> component. <mat-form-field>组件内部有<input>元素。

Usually, when I wrote element inside component, It wil be ignored. 通常,当我在组件内部编写元素时,它将被忽略。

How can I do this. 我怎样才能做到这一点。

Using <ng-content></ng-content> to slot your element. 使用<ng-content></ng-content>放置元素。

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

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

相关问题 实现2个组件,并在内部使用两个组件,就像角材料对其组件所做的一样 - Implementing 2 components and using both one inside another just like angular-material does with its component angular2 组件内的 iframe,“HTMLElement”类型上不存在属性“contentWindow” - iframe inside angular2 component, Property 'contentWindow' does not exist on type 'HTMLElement' 如何从 Angular 组件中的变量显示 HTMLElement? - How to display a HTMLElement from a variable in an Angular component? 如何在材质树组件内渲染 angular 组件 - How to render an angular component inside a material tree component 如何在 Angular Material 对话框组件中显示组件? - How to show a component inside Angular Material dialog component? 类型“JQuery”上不存在属性“涟漪”<HTMLElement> &#39;。 在角分量 - Property 'ripples' does not exist on type 'JQuery<HTMLElement>'. in angular component 如何将组件放在Angular2中的另一个组件中? - How to put a component inside another component in Angular2? 如何在Angular2 +中将组件放入另一个组件的templateUrl中? - How to put a component inside another component's templateUrl in Angular2+? 在角度材质中调用Dialog组件内的组件 - To call a component inside Dialog component in angular material 如何在组件内使用Angular 2 Material Sidenav? - How can I use Angular 2 Material Sidenav inside a component?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM