我正在尝试在我的父组件中定义一些html,这些html可以传递给子组件。这可能吗?我已经尝试了几件事,例如:如何将表达式作为Angular2中的输入传递给组件?,但是我没有任何运气。也许我的语法是错误的。我有点困惑let
。感谢所有帮助和任何解释,以帮助我更好地理解这一点。
@Component({
selector: 'app-my-parent',
template: `
<div>other parent html</div>
<app-my-child [property]="value">
<ng-template #someTemplate">value.first</ng-template>
</app-my-child>
<app-my-child [property]="value">
<ng-template #someTemplate">value.second</ng-template>
</app-my-child>
`
})
export class MyParent {
}
Run Code Online (Sandbox Code Playgroud)
@Component({
selector: 'app-my-child',
template: `
<div>other child html</div>
how do I access the template from here? Is there a way to do binding with templates?
})
export class MyChild {
@Input() property;
}
Run Code Online (Sandbox Code Playgroud) angular ×1