├── .gitignore ├── .jshintrc ├── LICENSE ├── README.md ├── bower.json ├── dist └── bsDropdown.min.js ├── example ├── index.html └── js │ └── app.js ├── gulpfile.js ├── package.json ├── src └── bsDropdown.js ├── template └── defaultTemplate.html └── test ├── bsDropdown-multiselect-test.js ├── bsDropdown-test.js └── karma.conf.js /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | bower_components 3 | *~ -------------------------------------------------------------------------------- /.jshintrc: -------------------------------------------------------------------------------- 1 | { 2 | "strict": true, 3 | "globals":{ 4 | "angular": false 5 | } 6 | } -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 AllenFang (方紹昌) 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | 23 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # angular-bootstrap-dropdown 2 | It's a angular directive for bootstrap dropdown, named 'bsDropdown' 3 | 4 | The bsDropdown include all basic function in dropdown, include set default value, and listen change etc. 5 | 6 | Also support multi-select on newest version. 7 | 8 | angular-bootstrap-dropdown dependencies on AngularJS 1.2.x and Bootstrap 3 9 | 10 | You can see an online demo on [here](http://frozen-tundra-7264.herokuapp.com/examples/L8/#). 11 | 12 | ### Versions 13 | 0.1.0 support basic function in bsDropdown, include use ng-model to set default value, and ng-change to listen change 14 | 15 | 0.1.1 add bootstrap divider in bsDropdown 16 | 17 | 0.2.0 add bootstrap dropdown disabled and item disabled in bsDropdown 18 | 19 | 0.9.0(latest) add multi-select to bsDropdown!! 20 | 21 | ### Development 22 | ``` 23 | $ git clone https://github.com/AllenFang/angular-bootstrap-dropdown.git 24 | $ cd angular-practice-example 25 | $ npm install 26 | $ bower install 27 | ``` 28 | Use gulp to test the bsDropdown 29 | ``` 30 | $ npm test 31 | or 32 | $ node_modules/gulp/bin/gulp.js test 33 | ``` 34 | 35 | 36 | ### Usage 37 | Include the angular-bootstrap-dropdown library to your html page 38 | ``` 39 | 40 | ``` 41 | The ```bsDropdown.min.js``` is in the dist folder. 42 | In the next, include the ```ng.bs.dropdown``` to your angular module dependencies 43 | ``` 44 | angular.module("demoApp", ['ng.bs.dropdown']) 45 | ``` 46 | Then, you can go to use the angular-bootstrap-dropdown, below is a simple example 47 | 48 | First of all, give an angular controller 49 | ``` 50 | angular.module("demoApp", ['ng.bs.dropdown']) 51 | .controller("YearController", function($scope){ 52 | $scope.years = [ 53 | "2015", 54 | "2014", 55 | "2013", 56 | "2012", 57 | "2011", 58 | "2010" 59 | ]; 60 | $scope.selectYear = $scope.years[2]; //current select item 61 | 62 | /*changeYear function will be called if dropdown change*/ 63 | $scope.changeYear = function(){ 64 | console.log("YearController say... " + $scope.selectYear); 65 | } 66 | }); 67 | ``` 68 | 69 | So here is your partial html code 70 | ``` 71 |
You select {{selectYear}} ....
17 | 22 |
70 |
71 | 1. Use bs-dropdown-display attribute in bsDropdown to specify the default text on dropdown
72 |
73 | 2. Use bs-dropdown-items(required) attribute in bsDropdown to specify the options you want to display in dropdown
74 |
75 | 3. Use ng-model(required) attribute in bsDropdown to specify the current selected option in dropndown.
76 | If no data you want to select on doopwodn default, you can give null value.
77 | For example, you can modify $scope.selectYear = null; in YearController in this example.
78 |
79 | 4. Use ng-change to listen a change event on bsDropdown.
80 |
81 | 5. Use bs-dropdown-divider to specify the divider, for example bs-dropdown-divider="{{[2,5]}}".
82 |
83 | 6. Use bs-dropdown-item-disabled to specify which option should be disabled,
84 | for example bs-dropdown-item-disabled="{{[2,5]}}".
85 |
86 | 7. Use bs-dropdown-disabled to set bsDropdown disabled, for example bs-dropdown-disabled="true".
87 |
88 | 8. Use bs-dropdown-multi to specify bsDropdown to be a multi-select dropdown.
89 |
90 |
91 |