PHPackages                             alexpechkarev/angular-ui-select - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. alexpechkarev/angular-ui-select

ActiveComponent[Utility &amp; Helpers](/categories/utility)

alexpechkarev/angular-ui-select
===============================

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

511JavaScript

Since Jul 16Pushed 10y ago1 watchersCompare

[ Source](https://github.com/alexpechkarev/angular-ui-select)[ Packagist](https://packagist.org/packages/alexpechkarev/angular-ui-select)[ RSS](/packages/alexpechkarev-angular-ui-select/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

AngularJS UI Select
-------------------

[](#angularjs-ui-select)

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

[![Screenshot](ui-select.png?raw=true "Angular JS UI Select")](ui-select.png?raw=true)

### Dependencies

[](#dependencies)

1. [AngularJS](https://angularjs.org/) - v1.3.8
2. [jQuery](http://jquery.com/) - v1.11.1
3. [Lo-Dash](https://lodash.com/) - v2.4.1
4. [Bootstrap](http://getbootstrap.com/) - v3.3.1

\###Demo

[Example](http://alexpechkarev.github.io/angular-ui-select/)

\###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

```

```

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` initialise data for select element and specify selected item :

```
  $scope.selectData = [
      {id:'0',  name: 'Select product type', shade:''},
      {id:'123',name:'black',  shade:'dark'},
      {id:'245',name:'white',  shade:'light'}
  ];

 $scope.selectedItem = $scope.selectData[0];
```

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.

```
  $scope.selectGroup = [];
  $scope.box = 0;
  $scope.addSelect = function() {
    $scope.selectGroup.push({box:$scope.box});
    $scope.box++;
  };
```

2. Responding to select behaviour method `setSelected()` obtains or updates 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](https://lodash.com/) library utilised to manage selected values in array.

```
  $scope.setSelected = function (index,item) {

      if(item.shade !== ""){

        $scope.currentItem = item;

        if(!_.find($scope.allItems,{'index':index}) ){

            $scope.allItems.push({index:index,item:item});

        }else{

            _.remove($scope.allItems, function(it) { return it.index === index; });
            $scope.allItems.push({index:index,item:item});
        }

      }

  };
```

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.

```
  $scope.removeSelect = function(box){

       $scope.currentItem = [];

       _.remove($scope.allItems, function(it) { return it.index === box; });

      if(_.find($scope.selectGroup,{'box':box}) ){
          _.remove($scope.selectGroup, function(it) { return it.box === box; });
      }
  };
```

\###Support

[Please open an issue on GitHub](https://github.com/alexpechkarev/angular-ui-select/issues)

\###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.

###  Health Score

21

—

LowBetter than 19% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 93.8% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://www.gravatar.com/avatar/1cc8e1ca17a8158b131c60f92d5c5243073bfa762fb34b9263c0fbc15f072132?d=identicon)[alexpechkarev](/maintainers/alexpechkarev)

---

Top Contributors

[![alexpechkarev](https://avatars.githubusercontent.com/u/5559162?v=4)](https://github.com/alexpechkarev "alexpechkarev (15 commits)")[![sanusart](https://avatars.githubusercontent.com/u/267718?v=4)](https://github.com/sanusart "sanusart (1 commits)")

### Embed Badge

![Health badge](/badges/alexpechkarev-angular-ui-select/health.svg)

```
[![Health](https://phpackages.com/badges/alexpechkarev-angular-ui-select/health.svg)](https://phpackages.com/packages/alexpechkarev-angular-ui-select)
```

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
