The @daffodil/navigation in-memory driver provides randomly generated menus for local development and testing when a backend is unavailable.
angular-in-memory-web-api under the hood@daffodil/navigation/testing factoriesimport { ApplicationConfig } from '@angular/core';
import { provideHttpClient } from '@angular/common/http';
import { provideDaffInMemoryDriver } from '@daffodil/driver/in-memory';
import { provideDaffNavigationInMemoryDriver } from '@daffodil/navigation/driver/in-memory';
export const appConfig: ApplicationConfig = {
providers: [
provideHttpClient(),
provideDaffInMemoryDriver(myConfig),
provideDaffNavigationInMemoryDriver(),
],
};
By default, the driver generates random data using DaffNavigationTreeFactory. To provide your own:
import { DaffNavigationTree } from '@daffodil/navigation';
const customNavigationTree: DaffNavigationTree = {
id: 'root',
url: '/',
name: 'Main Navigation',
breadcrumbs: [],
children: [
{
id: 'products',
url: '/products',
name: 'Products',
breadcrumbs: [{ id: 'root', name: 'Home', url: '/', level: 0 }],
children: [
{
id: 'category-1',
url: '/products/category-1',
name: 'Category 1',
total_products: 25,
breadcrumbs: [
{ id: 'root', name: 'Home', url: '/', level: 0 },
{ id: 'products', name: 'Products', url: '/products', level: 1 },
],
children: [],
},
{
id: 'category-2',
url: '/products/category-2',
name: 'Category 2',
total_products: 15,
breadcrumbs: [
{ id: 'root', name: 'Home', url: '/', level: 0 },
{ id: 'products', name: 'Products', url: '/products', level: 1 },
],
children: [],
},
],
},
{
id: 'about',
url: '/about',
name: 'About Us',
breadcrumbs: [{ id: 'root', name: 'Home', url: '/', level: 0 }],
children: [],
},
],
};
Then add it to your appConfig providers alongside provideDaffNavigationInMemoryDriver():
provideDaffNavigationInMemorySeedDataProvider(() => customNavigationTree)