我希望我的Pages
个人将不同的组件从其他组件注入Pages/Components
到header
. 例如,我想将我的Input
搜索字段注入content-component
到我的header
组件中。我试过了ng-Content
,但这只会header
在我的HTML
. 问题是我header
的不是每个Component
单独的,它在我的app.component
.
我的标题组件:
<div class="header__sub">
<div class="header__title header__title--sub">
<h2 class="title title--medium">{{ subtitle }}</h2>
</div>
<div class="header__search">
<!-- Here should be my Input field -->
<ng-content></ng-content>
</div>
我想注入输入字段的组件:
<app-header>
<mat-form-field>
<input matInput (keyup)="applyFilter($event.target.value)" placeholder="Search" />
</mat-form-field>
</app-header>
....
应用组件.html:
<mat-drawer-content>
// The header
<app-header-sub>
</app-header-sub>
<div class="content__inner">
// My Content
<router-outlet></router-outlet>
</div>
</mat-drawer-content>
如何从每个组件中单独注入不同的标签header
(具有功能)?