什么是PageSlotComponent
解决方案
理论依据
In Angular you can inject the closest parent component of a given type, by passing it as a constructor dependency.
You might want to add @Optional() decorator if you plan to use your component outside the content slot (i.e. as a static component). It will help avoid crashing app in the runtime, but will just resolve PageSlotComponent instance safely to null.
看一个运行时的例子:
Angular里可以很容易的通过依赖注入,在一个Component的构造函数里,注入其祖先引用作为依赖。这样,Component里就能访问其祖先实例上的数据。