Angular Router dynamic Sidebar without always manually setting the sidebar

Viewed 138

I'm working on an Angular application that uses the Router Outlet to dynamically load Content into the Sidebar. For example we do it like this

<a [routerLink]="['', {outlets: {primary: ['processing-directories', 'legal-entities', legalEntity.id],
                                 sidebar: ['processing-directories', 'legal-entities', legalEntity.id, 'selection']}}]">

The Sidebar should show something just in some cases and should be empty most of the time. Everytime the route is changed, we have to set the Sidebar manually to null to remove the Sidebar content.

<commons-breadcrumb-item [path]="['', {outlets: {primary: ['data-processings'], sidebar: null}}]"
                           label="HelloWOrld"></commons-breadcrumb-item>

This works fine but is very inconvenient because we have to do it in many places and everytime we forget doing it somewhere, the Sidebar keeps its content.

Is there a better way to configure the sidebar that it automatically changes when the route changes? Without manually setting it like in the example? Maybe something like one central sidebar configuration that is subscribed to the URL and automatically changes when the route changes?

0 Answers
Related