Routing
You can utilize the Angular Router and use the Drawer as a navigational component.
The Router enables you to load modules which act as root modules for specific paths. The Angular Router loads separate modules for separate components and bootstraps the components. This approach is useful when the paths do not share any main components—for example, public vs. admin sections. To use shared components, move the components into a shared module and import it in the separate module.
To set the functionality, use either of the following approaches:
- Use the
select
event to navigate to the route which is represented by the Drawer. - Use a template to add the
routerLink
directive to the item link. To expand the link element so it fits the whole Drawer item, you can apply thek-drawer-link
CSS class to it.
Generating the RouterLink Directive
This approach enables you to navigate to the routes upon clicking the Drawer items and by using the RouterLink
directive. The directive is generated from the routes that are available in the router configuration.
Getting the Selected Item
The following example demonstrates how to convert the routes to an array of DrawerItems
and navigate to the selected item route in the select
event.