Nav Menu Component
The NavigationMenuComponent is a flexible menu component designed to manage navigation items in Angular applications. It supports hierarchical menus, route-based active state highlighting, and optional logo display. The component integrates seamlessly with Angular's router and event-driven architecture.
How to use the component in your app :
import the component :
import { NavigationMenuComponent} from '@tradinos/cms-frontend-layout';The selector for component , like it :
<lib-cms-navigation-menu>
</lib-cms-navigation-menu>Features
Dynamic Menu: Renders navigation items dynamically from the
navigationItemsinput, supporting hierarchical menus with nested routes.Active Route Highlighting: Automatically highlights the active route based on the current URL.
Logo Display: Optionally displays a logo using the
showlogoinput.Event-Driven Sidebar Management: Emits a
SidebarEvent.closeevent when navigation occurs, allowing seamless integration with sidebars.
Inputs
Input
Type
Description
showlogo
boolean
Controls whether the logo is displayed in the navigation menu. Default: false.
expanded
boolean
Indicates whether the navigation menu is expanded or collapsed. Default: false.
routePrefix
string
A prefix added to all routes in the navigation menu.
navigationItems
NavigationItem[]
An array of navigation items defining the structure and hierarchy of the menu.
Methods
onNavigate()
Description: Emits a
SidebarEvent.closeevent to close the sidebar when a navigation item is clicked.Usage: Typically called when a menu item is clicked to trigger a sidebar close action.
isActiveRoute(router, item, prefix)
Description: Checks if the current route matches the route of the provided navigation item or its children.
Parameters:
router: The Angular router instance to get the current URL.item: The navigation item to check.prefix: The route prefix to prepend to the navigation item's route.
Returns:
trueif the current route matches the item's route or one of its children's routes; otherwisefalse.Purpose: Useful for highlighting the active route in the menu.
For example :
Last updated