angular-dropdown-multiselect
Angular JS directive for dropdown with multi-select feature.
Dependencies
AngularJS, Bootstrap
Usage
Include both .css
and .js
files in index.html
.
Inject dropdown-multiselect
as your angular app dependencies.
angular;
Features
Use as an element
```html ```or as an attribute
```html ```Provide custom name to the dropdown
My Custom Name
If no text is provided, it will default to text as Select
.
Settings through attribute:
dropdown-options
Provide data to be displayed as dropdown list items through dropdown-options="options"
attribute. It can accept the object in a format of:
HTML:
```html ```dropdown-trackby
Initially, dropdown items are tracked by Id
automagically, if the dropdown-trackby
attribute is not set.
If the option objects does not have Id
property, then custom tracking could be set by providing any of the property of an object from the options data.
HTML:
```html ```It is always better to provide dropdown-trackby
attribute for correct tracking.
dropdown-disable
Dropdown could be disabled by providing boolean value to dropdown-disable
attribute.
Or through the Controller:
$scopedropdownDisable = true;
and then in HTML:
model
The model
attribute gives the accessibility to the selected data from the dropdown which will be available to the view and the controller.
HTML:
<!--Binding to the view--> Selected Items = {{selectedItems | json}}
Controller:
//Binding to the controller var mySelectedValues = $scopeselectedItems;
Set through config in Controller:
Configure the options from the controller to set dropdown-config
.
NOTE: When dropdown-config
is being used, it will overwrite dropdown-options
and dropdown-trackby
attribute, if in use.
Available config
options:
options, trackBy, displayBy, divider, icon, displayBadge, height, filter
options:
trackBy:
displayBy:
divider:
icon:
displayBadge:
height:
filter:
Controller:
var options = 'Id': 1 'Name': 'Batman' 'Costume': 'Black' 'Id': 2 'Name': 'Superman' 'Costume': 'Red & Blue' 'Id': 3 'Name': 'Hulk' 'Costume': 'Green' ; $scopeconfig = options: options trackBy: 'Id' displayBy: 'Name' 'Costume' divider: ':' icon: 'glyphicon glyphicon-heart' displayBadge: true height: '200px' filter: true;
HTML:
Tested with