-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
How to make a dynamic sidebar menu? #161
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Hi @hleder-web |
The easiest option is to create an
@Injectable()
class AppSidebarService {
items$: Observable<INavData[]>;
constructor(private user: UserService) {
this.items$ = this.user.state$.pipe(
map(user => this.getSidebarItems(user)),
);
}
private getSidebarItems(user: User): INavData[] {
// logic depending on user context
return [ /* sidebar items */];
}
}
<app-sidebar-nav [navItems]="sidebar.items$ | async"></app-sidebar-nav> |
How |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions |
im trying to use use a json on the place of nav.ts to make the nav itens dynamic depending on the user, but i dont know how can i do it.
interface NavAttributes {
[propName: string]: any;
}
interface NavWrapper {
attributes: NavAttributes;
element: string;
}
interface NavBadge {
text: string;
variant: string;
}
interface NavLabel {
class?: string;
variant: string;
}
export interface NavData {
name?: string;
url?: string;
icon?: string;
badge?: NavBadge;
title?: boolean;
children?: NavData[];
variant?: string;
attributes?: NavAttributes;
divider?: boolean;
class?: string;
label?: NavLabel;
wrapper?: NavWrapper;
}
export const navItems: NavData[] = [
---------json here--------------
];
The text was updated successfully, but these errors were encountered: