将属性(属性指令)传递给模板

时间:2017-09-05 08:44:40

标签: angular attributes

假设我有一些属性指令:directive1,directive2和directive3。 我像这样使用它们

<someComponent directive1 directive3></someComponent>
<otherComponent></otherComponent>

我经常使用someComponent和otherComponent,我想将它们包装在wrapperComponent中。我希望wrapperComponent只具有config属性,我可以为someComponent和otherComponent传递所有配置,包括指令。

如何传递属性指令或从组件中设置它们,如下所示:

@Component({
  template: `
<someComponent {{config.directives}}></someComponent>
<otherComponent></otherComponent>
`
})
classWrapperComponent {
  @Input() config;
}

用法:

<wrapperComponent [config]="config"></wrapperComponent>

0 个答案:

没有答案
相关问题