Angular module that provides a multi-select dropdown list with checkboxes.
The required dependencies are:
- AngularJS (tested with version 1.2.28+)
This module was built with the intention of using it alongside UI Bootstrap.
For an example of so-multiselect in action, take a look at the demo app inside src/demo.
Alternatively, you can find the same example on plunker.
The easiest way to install the module is to use bower:
bower install sonalake/so-multiselect --save
bower update
Include the CSS and JS files in your index.html file:
<script src="so-multiselect.js"></script>
<link rel="stylesheet" href="so-multiselect.css">Declare dependencies on your module app like this:
angular.module('myModule', ['so.multiselect']);Set up your models in your controller:
$scope.flavours = [{
key: 'f1',
name: 'Strawberry'
}, {
key: 'f2',
name: 'Classico'
}, {
key: 'f3',
name: 'Mint'
}];
$scope.chosenFlavours = [];
$scope.onFlavourSelected = function(selectedItems) {
$scope.chosenFlavours = selectedItems;
};Apply the directive to your HTML:
<div so-multiselect items="flavourList" name="Flavours" on-selected="onFlavourSelected(selectedItems)" button-class="btn-grey"></div>itemstakes a reference to the array of object to appear in the dropdown list; each object must containkeyandnameattributes.nameis the value for the label that appears inside the trigger for the dropdown list.on-selectedtakes a reference to the callback function you want to execute when an item is selected in the list. TheselectedItemsparameter contains an array of the selected objects.button-classis an optional attirbute if you wish to add any extra CSS classes to the trigger for the dropdown list.
We are using npm, bower and grunt as part of our development process. To build the module from scratch, run the following commands:
npm install -g grunt-cli
npm install
bower install
grunt build
We use karma and protractor to ensure the quality of the code. To run the tests, run the following commands:
npm install -g grunt-cli
npm install
bower install
grunt test
Running the tests and building the application can be done together using the following commands:
npm install -g grunt-cli
npm install
bower install
grunt
