How do I inject a parent component into a child component?

前端 未结 2 1722
既然无缘
既然无缘 2020-11-27 16:24

I\'m trying to inject a parent component into a child component. I thought this would be straightforward – simply specify/inject the parent component in the child\'s

2条回答
  •  清歌不尽
    2020-11-27 16:34

    you could simply use @Host decorator like this:

    import {Component, Host} from 'angular2/core';
    ....
    constructor(@Host() private app: AppComponent)
    

提交回复
热议问题