angular-ui-select

AngularJS UI Select directive allows creating multiply drop-down lists with group related options.
0 people use it

AngularJS UI Select

This directive allows creating multiply drop-down lists with group related options. Value of selected options added to an array that available to AngularJS.

Screenshot

Dependencies

  1. AngularJS - v1.3.8
  2. jQuery - v1.11.1
  3. Lo-Dash - v2.4.1
  4. Bootstrap - v3.3.1

Demo

Example

Usage

How does it work? Simple. Directive tells compiler to attached specific behaviour and create drop-down element from template. To start, ensure all above dependencies are included as well as ui-select.js directive and selectCrt.js controller.

Add HTML markup for select element first

<group-select update="setSelected(select.box,item)" data="selectData" single="selectedItem" close="removeSelect(select.box)" ng-repeat="select in selectGroup"> </group-select>

Following attributes bind data with controller scope:

data="selectData" - drop-down data

single="selectedItem" - selected element by default

update="setSelected(select.box,item)" - specify selected element by given drop-down list

close="removeSelect(select.box) - remove given drop-down list

In the selectCrt.js initialising data for select element and setting selected item :

Three methods in controller respond to user behaviour:

  1. Add new drop-down list
  2. Get value of selected element
  3. Remove drop-down list

1) To add a new drop-down list addSelect() method has to be triggered, in this example it's a button click. This method adds new item (select box) to an array. Having unique counter helps referring to a specific drop-down list when retrieving / updating values or removing drop-down list from array of elements.

2) Responding to select behaviour method setSelected() obtains selected value from drop-down list. In this example default value is omitted. Single value per drop-down list will be stored in array of selected values, on changed event it's value will be updated accordingly. Lo-Dash library utilised to manage selected values in array.

3) To remove drop-down list method removeSelect() respond to this action. Selected value from given drop-down list being removed from array of values first and then drop-down list being removed it's self.

Support

Please open an issue on GitHub

License

The MIT License (MIT)

Copyright (c) 2014 Alexander Pechkarev

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

comments powered by Disqus
This page was last updated almost 3 years ago.