https://github.com/godbasin/angular-select2
select2 in angular(>=2.0-release).
https://github.com/godbasin/angular-select2
angular angular2 angular4 select2
Last synced: about 2 months ago
JSON representation
select2 in angular(>=2.0-release).
- Host: GitHub
- URL: https://github.com/godbasin/angular-select2
- Owner: godbasin
- License: mit
- Created: 2017-06-23T03:19:59.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2019-04-19T20:05:02.000Z (about 6 years ago)
- Last Synced: 2024-10-19T04:32:59.727Z (7 months ago)
- Topics: angular, angular2, angular4, select2
- Language: TypeScript
- Homepage:
- Size: 148 KB
- Stars: 15
- Watchers: 3
- Forks: 11
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Angular-Select2
This project was generated with [Angular CLI](https://github.com/angular/angular-cli) version 1.0.1.
## Instructions
This project is built for showing how to use angular-select2-component.# Angular-Select2-Component
Source code in: [https://github.com/godbasin/angular4-select2/tree/npm-publish-code](https://github.com/godbasin/angular4-select2/tree/npm-publish-code).
## Related Versions
Angular-Select2-Component is baseed on these plugins and libs(version):
- [angular(>= 2.0-release)](https://angular.io/)
- [jQuery](https://jquery.com/)
- [select2](https://select2.github.io/)## How to use
---
### Install
``` cmd
// npm install
npm install angular-select2-component --save// if you have not installed jquery
npm install jquery --save
```### Use as component
1. Import component.``` javascript
// import NgModule
import {NgModule} from '@angular/core';
// import Select2Component
import {Select2Component} from 'angular-select2-component';@NgModule({
// ...
// declare components
declarations: [Select2Component]
})
export class YourModule {
}
```2. Template.
``` html
```
3. Compile settings.
If you have set the `include` or `exclude` option in your `tsconfig.json`, you need to include the `node_modules/angular-select2-component/index.ts` file.
``` json
// tsconfig.json
{
// ... other options
"include": [
"node_modules/angular-select2-component/index.ts"
]
}
```### Options
- `options`: `option[]`
- select options for select2
- `option`: `{id: value, text: key}` or `string`
- `ngModel`: option value that is selected
- `id` or `string` while multiple is disable
- `id[]` or `string[]` while multiple is enable
- `onSelect`
- callback when option selected
- parmas: `option`(`{id: value, text: key, selected: ifSelected}` or `string`)
- `settings`
- configurable settings, see [Select2 options API](https://select2.org/configuration/options-api)
- `setting`: `{ settingOption: value, settingOption: value }`