Here's the issue at hand:
- I'm facing a problem with my Dashboard component. The Dashboard consists of a Sidebar and Navbar as child components.
- On the Sidebar, I have applied a custom permission directive to the links to determine if the user has permission to view them or not.
- The Navbar includes options for Admin, Manager, and staff roles. Whenever the user changes roles, I need to update the sidebar links based on the new scope permissions.
I attempted to pass an observable to the sidebar like this:
scope$: Observable<Roles> = this.scopeService.scope$;
using the async pipe:
<app-sidebar [scope]="scope$ | async"></app-sidebar>
and subscribing in the ngOnInit method:
ngOnInit(): void {
this.scopeService.scope$.subscribe();
}
However, this approach didn't work as expected. I've come across suggestions to use event emitters, but I prefer a declarative pattern for this task.
For more details, you can check out this stackblitz link.