I have the following tag in my html template.
<router-outlet (activate)="componentAdded($event)"></router-outlet>
I have the following tag in my component class.
componentAdded($event: EventEmitter<any>) {
console.log($event);
}
I'm gettin result like below.
MyComponent {formBuilder: FormBuilder, route: ActivatedRoute, router: Router, loginService: LoginService, cookieService: CookieService, …}
我需要捕捉这个“MyComponent”值。
最佳答案
此时 $event
是一个简单的 javascript 对象。
要获取类名,您可以键入 $event.constructor.name
,这将生成 MyComponent
。
关于angular - 我需要通过路由器导出激活方法在路由器导出中获取组件名称,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53532956/