Dear all,
I hope everyone is well. I am building menu using json object in Angular 11.
I am able to do upto single level.
What I want is if there is any sub menu then it should be open on hover.
eg. :-
master => user
what I am expecting is :-
master => user => 1. Staff 2. Student
If I hover on Staff then it contains again sub menu like Non Teaching and Teaching and so on.
here I have piece of code :-
- class="chk-nav">
-
- class
="nav-item" menuToggleLink *ngFor="let menuitem of menuItems.getAll()" - [ngClass]="{'menu-item-has-child': menuitem.type=='sub'}">
- "_blank" href="{{menuitem.state}}"
- *ngIf="menuitem.type === 'ext-link'" tourAnchor="tour-ui">
- class="{{ menuitem.icon }}">
-
class
="text-nowrap mb-0"> - {{ menuitem.name | translate }}{{menuitem.label}}
- "['/', menuitem.state]" routerLinkActive="activelink" *ngIf="menuitem.type === 'link'">
- class="{{ menuitem.icon }}">
-
class
="text-nowrap mb-0"> - {{ menuitem.name | translate }}
-
"menuitem.label" > - class="sidebar-label">{{menuitem.label}}
- "javascript:void(0)" *ngIf="menuitem.type === 'sub'">
- class="{{ menuitem.icon }}">
-
class
="text-nowrap mb-0"> - {{ menuitem.name | translate }}
- class="fa fa-caret-down" aria-hidden="true">
-
"menuitem.label" > - class="sidebar-label">{{menuitem.label}}
-
- class
-
- class
="nav-item" *ngFor="let childitem of menuitem.children" routerLinkActive="open"> - "['/', menuitem.state, childitem.state ]" routerLinkActive="active-link">
- class="icon icon-arrows-right-double">
-
class
="text-nowrap mb-0">{{ childitem.name | translate}} -
"childitem.label" > - class="sidebar-label">{{childitem.label}}
- Menu
- export interface ChildrenItems {
- state: string;
- name: string;
- type?: string;
- label?: string;
- }
- export interface Menu {
- state: string;
- name: string;
- type: string;
- icon: string;
- label?: string;
- children?: ChildrenItems[];
- }
- const MENUITEMS = [
- {
- state: 'dashboard',
- name: 'DASHBOARD',
- type: 'link',
- icon: 'icon-speedometer icons',
- label: 'New'
- },
- {
- state: 'courses',
- name: 'COURSES',
- icon: 'icon-graduation icons',
- label: 'New',
- type: 'sub',
- children: [
- { state: 'courses', name: 'COURSES' },
- { state: 'course-detail', name: 'COURSE DETAIL' },
- { state: 'course-signin', name: 'SIGN IN' },
- { state: 'course-payment', name: 'PAYMENT' }
- ]
- },
- {
- state: 'user',
- name: 'MANAGEMENT',
- type: 'sub',
- icon: 'icon-organization icons',
- label: 'New',
- children: [
- { state: 'management-list', name: 'USER LIST' },
- { state: 'management-grid-list', name: 'USER GRID' }
- ]
- }
- ];
Please suggest me how can I achieve this.
Thanking you,
Regards.
Sachin SinghPosted Jan 7, 2021, 8:37 AM
Kiran MohantyPosted Jan 7, 2021, 8:40 AM