如何在代码库中找到父组件-angular 5?

时间:2018-07-10 05:42:07

标签: angular

我想从子组件中找到父组件的名称。是否可以从子组件中获取父组件的名称?

1 个答案:

答案 0 :(得分:0)

Example

HTML:

父组件:

context

子组件:

context

TS:

父组件:

<hello [parent]="'parentCoponent'" (output)="outputEvent($event)" ></hello>
<p>
  Hello My Child is {{childComponent}}
</p>

子组件:

<h1>Hello My Parent Is {{parent}}</h1>