小编Aba*_*Aba的帖子

Angular 6嵌套模板视图

我是Angular的新手(我正在使用Angular 6),我想在布局视图中定义一些“插入内容块”。

例如:

<!-- layout.component.html -->
<div>{{my.title.component}}</div>
<div>{{my.body.component}}</div>
Run Code Online (Sandbox Code Playgroud)

然后,我希望能够执行以下操作:

<!-- title.component.html -->
<h1>I am the title</h1>
Run Code Online (Sandbox Code Playgroud)

对于身体:

<!-- body.component.html -->
<p> I am a very complex component inserted up there </p>
Run Code Online (Sandbox Code Playgroud)

然后,我想创建如下内容:

<!-- assembled.component.ts -->
@MagicalDecorator({
   layout: LayoutComponent,
   use_as_title_component: TitleComponent,
   use_as_body_component: BodyComponent,
}
Run Code Online (Sandbox Code Playgroud)

我可以做这样的事吗?我可能使用了错误的方法,但这就是我想象的那样。如果有更好的方法,我也想知道。

编辑: 我的想法是我希望能够使用布局组件添加格式(例如,将它们放在引导面板中),而不必为要使用相同布局的每个组件组合重复相同的格式

angular angular6

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

标签 统计

angular ×1

angular6 ×1