Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jagdeep-singh/angularMultipleSelect
A complete Angularjs directive for multiple select autocomplete
https://github.com/jagdeep-singh/angularMultipleSelect
Last synced: 3 months ago
JSON representation
A complete Angularjs directive for multiple select autocomplete
- Host: GitHub
- URL: https://github.com/jagdeep-singh/angularMultipleSelect
- Owner: jagdeep-singh
- License: mit
- Created: 2015-12-09T05:38:51.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2018-11-14T11:40:54.000Z (almost 6 years ago)
- Last Synced: 2024-07-17T21:04:24.068Z (4 months ago)
- Language: JavaScript
- Size: 138 KB
- Stars: 50
- Watchers: 6
- Forks: 37
- Open Issues: 23
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# angularMultipleSelect
A complete Angularjs directive for multiple select autocomplete
http://jagdeep-singh.github.io/angularMultipleSelect/#Sample View
https://cloud.githubusercontent.com/assets/13271120/11739891/b2d3e426-a014-11e5-9b57-a0d758f07bf0.png#Example
http://run.plnkr.co/plunks/XbHaZSiYqEzxjk6TuWyj/#Event listeners
1. beforeSelectItem : Listen for event before adding an item```javascript
$scope.beforeSelectItem = function(item){
// perform operation on this item before selecting it.
}
```
```html```
2. afterSelectItem : Listen for event before adding an item
```javascript
$scope.afterSelectItem = function(item){
// perform operation on this item after selecting it.
}
```
```html```
3. beforeRemoveItem : Listen for event before adding an item
```javascript
$scope.beforeRemoveItem = function(item){
// perform operation on this item before removing it.
}
```
```html```
4. afterRemoveItem : Listen for event before adding an item
```javascript
$scope.afterRemoveItem = function(item){
// perform operation on this item after removing it.
}
```
```html```
5. close-after-selected : To make the list close after selected an item
```html
```6. placeholder : Set placeholder
```html
```#Getting started
Install "angular-multiple-select" from bower or npm and save it in your package.json or bower.json.
For Example :```sh
$ npm install --save angular-multiple-select;
$ bower install --save angular-multiple-select
```After installation include its
```html
multiple-select.min.css AND
multiple-select.min.js```
in your html. Then,Include `multipleSelect` module in your app:
For example :```javascript
angular.module('yourModuleName', [
'multipleSelect'
]);
```
Now angularMultipleSelect module is injected in your module. You are ready to use it.You can use it in 2 ways in your form :
1. If your options list is an array of objects, like :```javascript
$scope.optionsList = [
{id: 1, name : "Java"},
{id: 2, name : "C"},
{id: 3, name : "C++"},
{id: 4, name : "AngularJs"},
{id: 5, name : "JavaScript"}
];
```
```html```
Here, in "suggestions-arr" you have to provide the options list from which user can select multiple value.
and, "object-property" is which you want to show to user. In above example "name" is the property which i want to show."ng-model" will give you an array of selected things.
For Ex : If user selects Java & C++, then
```javascript
ng-model will have
selectedList = [
{id: 1, name : "Java"},
{id: 3, name : "C++"}
]
```
2. If your options list is an array of strings, like :```javascript
$scope.optionsList = [
"Java",
"C",
"C++",
"AngularJs",
"JavaScript"
];
```
```html```
Here, in "suggestions-arr" you have to provide the options list from which user can select multiple value."ng-model" will give you an array of selected things.
For Ex : If user selects Java & C++, then
```javascript
ng-model will have
selectedList = [
"Java",
"C++"
]
```3. To make it required Field in a form
```html
3. Making it Required field in a Form
Please select something from multiple select field
Submit Form```
4. Fetching options list from 3rd party api/url
You can specify "api-url-option" and you can process response before we capture it. Below is the Example :
```javascript
$scope.apiUrlOption = {
method : "GET",
responseInterceptor : function (response) {
/*
*
* Process response acc. to your requirement.
* After processing we are assuming "response.data" as "suggestionsArr".
*
* */
}
};
```
Then in html no need to specify property in "object-property" attribute in directive
```html
```Part 1. If your Api return an array of strings like :
```javascript
[
"Java",
"C",
"C++",
"AngularJs",
"JavaScript"
]
```
Then in html no need to specify property in "object-property" attribute in directive
```html
```Part 2. If your Api return an array of objects like :
```javascript
[
{id: 1, name : "Java"},
{id: 2, name : "C"},
{id: 3, name : "C++"},
{id: 4, name : "AngularJs"},
{id: 5, name : "JavaScript"}
]
```
Then in html you need to specify property in "object-property" attribute in directive
Here in this case, you have to do like this :
```html
```For any suggestions, issues, Query, etc. Please feel free to let me know. Thanks :)
# The MIT License (MIT)
Copyright (c) 2015 Jagdeep Singh
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.