{"id":16749623,"url":"https://github.com/alexpechkarev/angular-ui-select","last_synced_at":"2025-04-10T14:11:33.694Z","repository":{"id":25140188,"uuid":"28562404","full_name":"alexpechkarev/angular-ui-select","owner":"alexpechkarev","description":"AngularJS UI Select directive allows creating multiply drop-down lists with group related options.","archived":false,"fork":false,"pushed_at":"2015-07-16T12:16:55.000Z","size":252,"stargazers_count":5,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-05T04:14:21.155Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://alexpechkarev.github.io/angular-ui-select/","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/alexpechkarev.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-12-28T13:27:09.000Z","updated_at":"2024-06-13T11:25:13.000Z","dependencies_parsed_at":"2022-07-10T11:46:17.395Z","dependency_job_id":null,"html_url":"https://github.com/alexpechkarev/angular-ui-select","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alexpechkarev%2Fangular-ui-select","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alexpechkarev%2Fangular-ui-select/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alexpechkarev%2Fangular-ui-select/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alexpechkarev%2Fangular-ui-select/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/alexpechkarev","download_url":"https://codeload.github.com/alexpechkarev/angular-ui-select/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248232444,"owners_count":21069487,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-13T02:25:25.605Z","updated_at":"2025-04-10T14:11:33.662Z","avatar_url":"https://github.com/alexpechkarev.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"## AngularJS UI Select\nThis directive allows creating multiple drop-down lists with group related options. Value of selected options added to an array that available to AngularJS.\n\n![Screenshot](ui-select.png?raw=true \"Angular JS UI Select\")\n\n### Dependencies\n\n1. [AngularJS](https://angularjs.org/) - v1.3.8\n2. [jQuery](http://jquery.com/) - v1.11.1\n3. [Lo-Dash](https://lodash.com/) - v2.4.1\n4. [Bootstrap](http://getbootstrap.com/) - v3.3.1\n\n\n###Demo\n\n[Example](http://alexpechkarev.github.io/angular-ui-select/)\n\n###Usage\n\nHow does it work? Simple. Directive tells compiler to attached specific behaviour and create drop-down element from template. \nTo start, ensure all above dependencies are included as well as `ui-select.js` directive and `selectCrt.js` controller.\n\nAdd HTML markup for select element first\n\n```html\n    \u003cgroup-select update=\"setSelected(select.box,item)\"  \n        data=\"selectData\" \n        single=\"selectedItem\" \n        close=\"removeSelect(select.box)\"  \n        ng-repeat=\"select in selectGroup\"\u003e\n    \u003c/group-select\u003e\n```\n\nFollowing attributes bind data with controller scope:\n\n `data=\"selectData\"`   - drop-down data \n\n `single=\"selectedItem\"`  - selected element by default\n\n `update=\"setSelected(select.box,item)\"` - specify selected element by given drop-down list\n\n `close=\"removeSelect(select.box)` - remove given drop-down list\n\n\nIn the `selectCrt.js` initialise data for select element and specify selected item :\n\n```javascript\n  $scope.selectData = [\n      {id:'0',  name: 'Select product type', shade:''},\n      {id:'123',name:'black',  shade:'dark'},\n      {id:'245',name:'white',  shade:'light'}     \n  ];\n\n $scope.selectedItem = $scope.selectData[0]; \n```\n\nThree methods in controller respond to user behaviour:\n\n1. Add new drop-down list\n2. Get value of selected element\n3. Remove drop-down list\n\n\n\n1) 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.\n\n```javascript\n  $scope.selectGroup = [];\n  $scope.box = 0;\n  $scope.addSelect = function() {\n    $scope.selectGroup.push({box:$scope.box});\n    $scope.box++;\n  };\n```\n\n\n2) 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. \n\n```javascript\n  $scope.setSelected = function (index,item) {\n      \n      if(item.shade !== \"\"){\n      \n        $scope.currentItem = item;\n      \n        if(!_.find($scope.allItems,{'index':index}) ){\n\n            $scope.allItems.push({index:index,item:item});\n\n        }else{\n\n            _.remove($scope.allItems, function(it) { return it.index === index; });\n            $scope.allItems.push({index:index,item:item});\n        }\n      \n      }\n        \n  };\n```\n\n\n3) 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.\n\n```javascript\n  $scope.removeSelect = function(box){\n      \n       $scope.currentItem = [];\n\n       _.remove($scope.allItems, function(it) { return it.index === box; });\n\n      if(_.find($scope.selectGroup,{'box':box}) ){\n          _.remove($scope.selectGroup, function(it) { return it.box === box; });\n      }\n  };\n```\n\n\n\n\n###Support\n\n[Please open an issue on GitHub](https://github.com/alexpechkarev/angular-ui-select/issues)\n\n\n###License\n\nThe MIT License (MIT)\n\nCopyright (c) 2014 Alexander Pechkarev\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falexpechkarev%2Fangular-ui-select","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falexpechkarev%2Fangular-ui-select","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falexpechkarev%2Fangular-ui-select/lists"}