2016-05-23 12:13:30 +03:00
---
title: Sidebar
author: vl
sort: 900
group: Components
template: article.jade
---
2016-07-16 12:35:09 -04:00
The sidebar provides a convenient way to navigate the application.
Only one sidebar is supported per angular application.
2016-09-19 12:20:34 -04:00
This means that the sidebar is basically a singleton object.
2016-05-23 12:13:30 +03:00
2016-09-19 12:20:34 -04:00
The Sidebar can be added to the page using the `BaSidebar` component:
2016-05-23 12:13:30 +03:00
```html
< ba-sidebar > < / ba-sidebar >
```
2016-07-16 12:35:09 -04:00
The sidebar contains a `<ba-menu></ba-menu>` component which defines and renders the application menu based on routes provided. Generally the `ba-menu` component can be used separately from `ba-sidebar` .
All menu items information is defined inside the `data` property of a route.
2016-05-23 12:13:30 +03:00
2016-05-24 13:29:46 +03:00
## Menu Configuration
2016-05-23 12:13:30 +03:00
2016-07-16 12:35:09 -04:00
All menu items are located inside the `src/app/app.routes.ts` file. Each route item can have a `menu` property under `data` defining a menu item:
2016-05-23 12:13:30 +03:00
```javascript
2016-05-24 13:29:46 +03:00
{
2016-07-12 13:49:07 +03:00
// first, router configuration
path: 'dashboard',
component: Dashboard,
data: {
2016-07-16 12:35:09 -04:00
// here additionaly we define how the menu item should look
2016-07-12 13:49:07 +03:00
menu: {
title: 'Dashboard', // menu title
icon: 'ion-android-home', // menu icon
selected: false, // selected or not
expanded: false, // expanded or not (if item has children)
2016-08-22 23:24:43 +03:00
order: 0, // item order in the menu list,
2016-08-22 23:26:49 +03:00
hidden: true // hide menu item from a list but keep related features (breadcrumbs, page title)
2016-07-12 13:49:07 +03:00
}
}
2016-05-24 13:29:46 +03:00
}
2016-05-23 12:13:30 +03:00
```
2016-07-12 13:49:07 +03:00
2016-05-24 13:29:46 +03:00
You also can define a list of sub-menu items like this:
2016-05-23 12:13:30 +03:00
```javascript
2016-05-24 13:29:46 +03:00
{
2016-07-12 13:49:07 +03:00
// parent route
path: 'charts',
component: Charts,
data: {
// parent menu configuration
menu: {
title: 'Charts',
icon: 'ion-stats-bars',
selected: false,
expanded: false,
order: 200,
}
},
// children routes
children: [
2016-05-24 13:29:46 +03:00
{
2016-07-12 13:49:07 +03:00
path: 'chartist-js',
component: ChartistJs,
data: {
// children menu item configuration
menu: {
title: 'Chartist.Js',
}
}
}
2016-05-24 13:29:46 +03:00
]
}
2016-05-23 12:13:30 +03:00
```
2016-07-12 13:49:07 +03:00
# Custom menu items
2016-05-23 12:13:30 +03:00
2016-07-12 13:49:07 +03:00
You also can define a menu item not connected to any existing route in the application:
2016-05-23 12:13:30 +03:00
2016-07-12 13:49:07 +03:00
```javascript
{
path: '', // just leave the path empty
data: {
// and define your menu item
menu: {
title: 'External Link', // title
url: 'http://akveo.com', // custom url
icon: 'ion-android-exit', // icon
order: 800, // order
target: '_blank' // target property of < a > tag (_self, _blank, etc)
}
}
}
2016-07-16 12:35:09 -04:00
```