# AngularJS multi-level accordion
- Allows for a nested structure
- Works with (or without) `ng-repeat`
- Allows multiple sections to be open at once
- Optimized for mobile devices
## Demos
- [GitHub](http://lukaszwatroba.github.io/v-accordion)
- [CodePen](http://codepen.io/LukaszWatroba/pen/pvEOBZ)
## Usage
- If you use [bower](http://bower.io/), just `bower install v-accordion`. If not, download files [from the github repo](./dist).
- Include `angular.js`, `angular-animate.js`, `v-accordion.js`, and `v-accordion.css`:
```html
```
- Add `vAccordion` as a dependency to your application module:
```js
angular.module('myApp', ['vAccordion']);
```
- Put the following markup in your template:
```html
Pane header #1
Pane content #1
Pane header #2
Pane content #2
```
- You can also use `v-accordion` with `ng-repeat`:
```html
{{ pane.header }}
{{ pane.content }}
{{ subpane.header }}
{{ subpane.content }}
```
## API
Use API methods to control accordion component:
```html
{{ pane.header }}
{{ pane.content }}
```
#### Methods
- `toggle(paneIndex)`
- `expand(paneIndex)`
- `collapse(paneIndex)`
- `expandAll()`
- `collapseAll()`
#### Events
- `vAccordion:onExpand`
- `vAccordion:onExpandAnimationEnd`
- `vAccordion:onCollapse`
- `vAccordion:onCollapseAnimationEnd`
## Callbacks
Use these callbacks to get expanded/collapsed pane index:
```html
{{ pane.header }}
{{ pane.content }}
```
```js
$scope.expandCallback = function (index) {
console.log('expanded pane index:', index);
};
$scope.collapseCallback = function (index) {
console.log('collapsed pane index:', index);
};
```
## Accessibility
vAccordion manages keyboard focus and adds some common aria-* attributes. BUT you should additionally place the `aria-controls` and `aria-labelledby` as follows:
```html
{{ pane.header }}
{{ pane.content }}
```