首页 > 解决方案 > Angular 从路由器出口组件获取 ElementRef

问题描述

要从路由器插座获取组件实例,我可以使用

<router-outlet (activate)="onRouterActivate($event)"></router-outlet>

我可以在我的方法中捕捉到这一点:

  public onRouterActivate(componentRef) {
    this.componentRef = componentRef;
  }

但是我如何获得底层componentRef的nativeElement/ ?ElementRefnativeElement属性似乎不存在于通过的内容(activate)

标签: angular

解决方案


推荐阅读