Angular 在特定零件中加载角度2组件
我的目标是在面板组件中加载表组件,所以基本上 我有3个部分:Angular 在特定零件中加载角度2组件,angular,Angular,我的目标是在面板组件中加载表组件,所以基本上 我有3个部分: @Component({ selector: 'parent', template: '<h1>Title!</h1><div #child></div>', }) export class ParentComponent { title = 'Parent' } 只需在父模板中使用子选择器 <h1>Title!</h1> <child>
@Component({
selector: 'parent',
template: '<h1>Title!</h1><div #child></div>',
})
export class ParentComponent {
title = 'Parent'
}
只需在父模板中使用子选择器
<h1>Title!</h1>
<child></child> <!-- will contains <div>I'm the child</div> -->
<other-child></other-child> <!-- will contains <div>I'm the other</div> -->
标题!
您可以执行类似于
的操作,然后在父控制器中设置选择器
;这是一个非常僵化的设计,总体上……你应该考虑用<代码> NGCuffTeCurruts<代码>来设计。我想加载dinamicllyok,您应该在问题中指定。不管怎样,它似乎就是你要找的
load('#child',OtherChildComponent)
<h1>Title!</h1>
<child></child> <!-- will contains <div>I'm the child</div> -->
<other-child></other-child> <!-- will contains <div>I'm the other</div> -->