Get current outlet name

Viewed 241

I have the following URL: http://localhost:6002/S8R4oL_nDk8-/a0_ksrURM10-/inspections/list/(inspection:bulk-assign) and what I'm trying to do is to get the outlet name (bulk-assign) but I can't find an elegant solution for this.

I just found this one Get current named outlet from url but it's so ugly. Isn't there any other possibility to do that?

2 Answers

Another solution that I've found is this.activatedRoute.snapshot.children[0].routeConfig.path.

It looks like the ActivatedRouteSnapshot contains a property called outlet, which seems to be what you're looking for:

export class ActivatedRouteSnapshot {
  /** @internal */
  constructor(
      /** The URL segments matched by this route */
      public url: UrlSegment[],
      /* ... */,
      /** The outlet name of the route */
      public outlet: string,
      /* ... */
      ) {}
  /* ... */
}

Source code.

Related