[Fixed] i need to get component name in the router-outlet through router-outlet activate method

Issue

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, …}

i need to catch this “MyComponent” value.

Solution

At that point $event is a simple javascript object.

To get class name, you can type $event.constructor.name which will result in MyComponent.

Leave a Reply

(*) Required, Your email will not be published