Following-up from my previous-post, I was able to set up nested navigation nodes on my navigator as follows:
import { Injectable } from "@angular/core";
import { NavigatorNode, NavigatorNodeFactory } from "@c8y/ngx-components";
@Injectable()
export class CaseManagementFactory implements NavigatorNodeFactory {
get(): NavigatorNode {
const caseManagementNode = new NavigatorNode({
label: 'Dashboard',
icon: 'dashboard',
path: 'case-management',
priority: 30
})
const openCasesNode = new NavigatorNode({
label: 'Open Cases',
icon: 'table',
path: 'case-management/open-cases',
priority: 20
});
caseManagementNode.add(openCasesNode);
return caseManagementNode;
}
}
I then import the factory into my component’s module as follows:
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { hookNavigator } from '@c8y/ngx-components';
import { CaseManagementComponent } from './case-management.component';
import { CaseManagementFactory } from './case-management.factory';
import { OpenCasesComponent } from './open-cases/open-cases.component';
import { ActiveCasesComponent } from './active-cases/active-cases.component';
@NgModule({
declarations: [CaseManagementComponent, OpenCasesComponent, ActiveCasesComponent],
imports: [
CommonModule
],
exports: [CaseManagementComponent],
providers: [hookNavigator(CaseManagementFactory)]
})
export class CaseManagementModule { }
Result
The difficulty I am facing now is trying to get the child component, open-cases, to appear in the main application space. This component should have the same default message as its parent component .
Because I intend to add a header to my application, I have also created a routing module for the parent component (and module) case-management, and I wonder if there is a conflict between the routing module and the navigator node factory both sharing the path
fields.
CaseManagementRoutingModule
import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import { CaseManagementComponent } from './case-management.component';
import { OpenCasesComponent } from './open-cases/open-cases.component';
const routes : Routes = [
{
path: '',
component: CaseManagementComponent,
children: [
{ path: 'open-cases', component: OpenCasesComponent}
]
}
]
@NgModule({
imports: [RouterModule.forChild(routes)],
exports: [RouterModule]
})
export class CaseManagementRoutingModule {}
AppRoutingModule
import { NgModule } from '@angular/core';
import { RouterModule, Routes } from '@angular/router';
const routes: Routes = [
{
path: 'case-management',
loadChildren: () => import('./features/case-management/case-management-routing.module').then(m => m.CaseManagementRoutingModule)
},
{
path: '',
redirectTo: 'case-management',
pathMatch: 'full'
}
];
@NgModule({
imports: [RouterModule.forRoot(routes, { enableTracing: false, useHash: true })],
exports: [RouterModule]
})
export class AppRoutingModule { }