angular2-expandable-list
Expandable lists made easy for Angular2+
Angular2 Expandable List is an HTML <angular2-expandable-list>
tag enhanced with styling and animation.
now compatible with Angular4 too.
Plunker DEMOs:
Table of contents
Installation
- Install the component using
npm
:
# To get the latest stable version and update package.json file: $ npm install angular2-expandable-list --save
or yarn
with:
$ yarn add angular2-expandable-list
Setup
If you are using System.js you may want to add this into map
and package
config:
If you are using Webpack you may want to add this into your vendor.js
file:
// vendor.ts;;;;; // Third parties packages;;
angular2-expandable-list class is an Angular2 module therefore, it needs to be registered in the modules array (encouraged way):
// app.module.ts;;;; @
Usage
Use the component anywhere around your application:
// app.component.ts; @
Design your list
List and list-item
The Angular2-expandable-list is composed of a <expandable-list>
wrapper and
one or more <expandable-list-item>
.
Start your list creating these 2 html tags in your template like this:
Title and secondary
Now, each <expandable-list-item>
needs a title and a list of elements.
It is possible to create both a primary and a secondary title for each item like
the following example.
Primary Title Secondary
List items
Now you're ready to fill your list with some items.
Primary Title Secondary Google Google Google
It is important to append the html attribute item
to each of the item you want
to be rendered in the list and it's up to you which HTML tag to use. We've just filled
our list with anchor link but feel free to use any other tag.
Dividers
Primary Title Secondary Google Google Google
Create more
Now you can create as many <expandable-list-item>
nodes as you want inside
your <expandable-list>
.
Primary Title Secondary Google Google Google Another list Google Google
Demo App
Have a look at the demo available in this repository for a real Angular2 application using the Angular2-Cookie-Law library.
From your terminal all the Node dependencies using npm:
$ npm run demo
Open your browser to http://localhost:9007/ to see the application running.
Options
Properties
isExpanded
Type | Default value |
---|---|
boolean | false |
Used for interacting with the expandable-list-item
element.
Example:
Attributes
Name | Type | Description |
---|---|---|
disabled | boolean | When applied to the expandable-list-item , disabled the |
is-expanded | boolean | Reflect the expandable state of the item list element |
Events
Name | Type | Description |
---|---|---|
onExpanded | boolean | Triggered when the list expansion status changes |
Example:
Angular 4
This module will work with Angular 4 projects but requires @angular/animations
to be included in your project as the Angular animations are not part of the @angular/core
library starting from the version >=4.
Make sure to include the BrowserAnimationsModule
in your App module like in the following example:
;;; ;
Everything else will just work as before.
Contributing
This package is using the AngularJS commit messages as default way to contribute with commitizen node package integrated in this repository.
- Fork it!
- Create your feature branch:
git checkout -b my-new-feature
- Add your changes:
git add .
- Commit your changes:
npm run commit
- Push to the branch:
git push origin my-new-feature
- Submit a pull request 😎
Changelog
Changelog available here
License
MIT License © Andrea SonnY