2016-05-23 12:13:30 +03:00
---
title: Sidebar
author: vl
sort: 900
group: Components
template: article.jade
---
Sidebar is used to provide convenient way of navigation in the application.
2016-05-25 14:35:19 +03:00
Application supports only one sidebar per angular application.
2016-05-23 12:13:30 +03:00
That means sidebar is basically a singletone object.
2016-05-24 13:29:46 +03:00
Sidebar can be added to the page using `BaSidebar` component:
2016-05-23 12:13:30 +03:00
```html
< ba-sidebar > < / ba-sidebar >
```
2016-07-12 13:49:07 +03:00
The sidebar contains a `<ba-menu></ba-menu>` component which defines and renders application menu based on routes provided. Generally `ba-menu` component can be used separately from `ba-sidebar` .
All menu items information defined inside the `data` properly 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-12 13:49:07 +03:00
All menu items are located inside `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: {
// here additionaly we difine how the menu item should look like
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)
order: 0 // and item order in the menu list
}
}
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)
}
}
}
```