# Routing

You can utilize the [Angular Router](https://angular.dev/guide/routing/common-router-tasks) and use the PanelBar 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 `RouterLink` directive](https://www.telerik.com/kendo-angular-ui-develop/components/layout/panelbar/routing#using-routerlink-directive)
* [Use the Router service](https://www.telerik.com/kendo-angular-ui-develop/components/layout/panelbar/routing#using-router-service)

## Using RouterLink Directive

This approach enables you to navigate to the routes upon clicking the PanelBar items and by using the [`RouterLink`](https://angular.dev/api/router/RouterLink) directive. The directive is generated from the routes that are available in the router configuration.
To use the `routerLink` directive, you need to import the `RouterModule` in your module.

```html
<kendo-panelbar-item ...
    [selected]="route.path === selectedId"
    [routerLink]="'./' + route.path"
>
</kendo-panelbar-item>
```

The following example demonstrates how to use `routerLink` directive for each item in the PanelBar.

[Demo Source](https://demos.telerik.com/kendo-angular-ui/demos/layout/panelbar/routing/routerlink/source.txt)

## Using Router Service

To get the selected item, you can use the [`stateChange`](https://www.telerik.com/kendo-angular-ui-develop/components/layout/api/panelbarcomponent#statechange) event of the PanelBar. The event returns the selected item, which you can then use to navigate to the corresponding route. Use the [`navigate`](https://angular.dev/api/router/Router#navigate) method of the [`Router`](https://angular.dev/api/router/Router#router) service to navigate to a specific route.

```ts
public stateChange(data: PanelBarStateChangeEvent): void {
    ...
    this.router.navigate([`./${current.id}`], { relativeTo: this.route });
}
```

The following example demonstrates how to use the `stateChange` event to navigate to a specific route.

[Demo Source](https://demos.telerik.com/kendo-angular-ui/demos/layout/panelbar/routing/state_change_route/source.txt)

## Suggested Links

* [API Reference of the PanelBar](https://www.telerik.com/kendo-angular-ui-develop/components/layout/api/panelbarcomponent)
* [API Reference of the PanelBarItem](https://www.telerik.com/kendo-angular-ui-develop/components/layout/api/panelbaritemcomponent)
