|
3 lat temu | |
---|---|---|
.. | ||
demo | 3 lat temu | |
dist | 3 lat temu | |
src | 3 lat temu | |
test | 3 lat temu | |
.bower.json | 3 lat temu | |
.bowerrc | 3 lat temu | |
.editorconfig | 3 lat temu | |
.gitignore | 3 lat temu | |
.jshintrc | 3 lat temu | |
.yo-rc.json | 3 lat temu | |
LICENSE | 3 lat temu | |
README.md | 3 lat temu | |
bower.json | 3 lat temu | |
gulpfile.js | 3 lat temu | |
index.html | 3 lat temu | |
karma.conf.js | 3 lat temu | |
package.json | 3 lat temu |
ng-repeat
If you use bower, just bower install v-accordion
. If not, download files from the github repo.
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
<!-- add
multiple` attribute to allow multiple sections to open at once -->
Pane header #1
Pane content #1
Pane header #2
Pane content #2
- You can also use `v-accordion` with `ng-repeat`:
```html
<v-accordion class="vAccordion--dafault">
<v-pane ng-repeat="pane in panes" expanded="$first">
<v-pane-header>
{{ pane.header }}
</v-pane-header>
<v-pane-content>
{{ pane.content }}
<!-- accordions can be nested :) -->
<v-accordion ng-if="pane.subpanes">
<v-pane ng-repeat="subpane in pane.subpanes">
<v-pane-header>
{{ subpane.header }}
</v-pane-header>
<v-pane-content>
{{ subpane.content }}
</v-pane-content>
</v-pane>
</v-accordion>
</v-pane-content>
</v-pane>
</v-accordion>
Use API methods to control accordion component:
<v-accordion multiple control="accordion">
<v-pane ng-repeat="pane in panes">
<v-pane-header>
{{ pane.header }}
</v-pane-header>
<v-pane-content>
{{ pane.content }}
</v-pane-content>
</v-pane>
</v-accordion>
<button ng-click="accordion.toggle(0)">Toggle first pane</button>
<button ng-click="accordion.expandAll()">Expand all</button>
<button ng-click="accordion.collapseAll()">Collapse all</button>
toggle(paneIndex)
expand(paneIndex)
collapse(paneIndex)
expandAll()
collapseAll()
vAccordion:onExpand
vAccordion:onExpandAnimationEnd
vAccordion:onCollapse
vAccordion:onCollapseAnimationEnd
Use these callbacks to get expanded/collapsed pane index:
<v-accordion onexpand="expandCallback(index)" oncollapse="collapseCallback(index)">
<v-pane ng-repeat="pane in panes">
<v-pane-header>
{{ pane.header }}
</v-pane-header>
<v-pane-content>
{{ pane.content }}
</v-pane-content>
</v-pane>
</v-accordion>
$scope.expandCallback = function (index) {
console.log('expanded pane index:', index);
};
$scope.collapseCallback = function (index) {
console.log('collapsed pane index:', index);
};
vAccordion manages keyboard focus and adds some common aria-* attributes. BUT you should additionally place the aria-controls
and aria-labelledby
as follows:
<v-accordion>
<v-pane ng-repeat="pane in panes">
<v-pane-header id="pane{{$index}}-header" aria-controls="pane{{$index}}-content">
{{ pane.header }}
</v-pane-header>
<v-pane-content id="pane{{$index}}-content" aria-labelledby="pane{{$index}}-header">
{{ pane.content }}
</v-pane-content>
</v-pane>
</v-accordion>