-
Notifications
You must be signed in to change notification settings - Fork 0
qbit kit ng: QSidemenu
Manolo Edge edited this page Feb 25, 2021
·
3 revisions
Module that renders a sidenav menu, based on some config, and exposes a service that can manage the sidemenu.
import { QSidemenuModule } from '@qbitartifacts/qbit-kit-ng';
app.module.ts
{
imports: [QSidemenuModule]
}
app.component.html
<qbit-sidemenu></qbit-sidemenu>
Now create the list of items that the menu should render, there are various types of items, see examples
export const SIDEMENU_ITEMS: QSidemenuItem[] = [
{
name: 'dashboard',
icon: 'dashboard',
label: 'DASHBOARD',
route: '/dashboard',
permission: PermissionUser,
},
]
app.module.ts
providers: [
{
provide: QBIT_SIDEMENU_ITEMS,
useValue: SIDEMENU_ITEMS,
},
]
With the service we can open/close and toggle sidemenu:
constructor(public sidemenu: QSidemenuService) {
this.sidemenu.open();
this.sidemenu.closed();
this.sidemenu.toggle();
}
export interface QSidemenuItem {
name: string;
icon?: string;
label: string;
route?: string;
separator?: boolean;
action?: (...args: any[]) => any;
permission?: InternalPermission;
isExternal?: boolean;
keyValue?: boolean;
value?: any;
badge?: string;
}
{
name: 'dashboard',
icon: 'dashboard',
label: 'DASHBOARD',
route: '/dashboard',
permission: PermissionUser,
}
{
name: 'admin_separator',
separator: true,
label: 'ADMIN',
permission: PermissionAdmin,
}
{
name: 'panel_version',
keyValue: true,
label: 'PANEL',
value: environment.version,
permission: PermissionUser,
}