Skip to content

Commit

Permalink
Added multiple options
Browse files Browse the repository at this point in the history
Resolves #24
  • Loading branch information
NejcZdovc committed Dec 16, 2016
1 parent af513af commit 223f02f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 15 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ng2-select2",
"version": "0.7.0",
"version": "1.0.0-beta.0",
"description": "Angular2 wrapper for select2",
"main": "ng2-select2.js",
"typings": "ng2-select2.d.ts",
Expand Down
28 changes: 14 additions & 14 deletions src/select2.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -504,21 +504,23 @@ export class Select2Component implements AfterViewInit, OnChanges, OnDestroy {

// data for select2 drop down
@Input() data: Array<Select2OptionData>;
@Input() value: any;

@Output() valueChanged = new EventEmitter();
@Output() blur = new EventEmitter();
// value for select2
@Input() value: any;

// Optional options for select2
// width of select2 input
@Input() width: string;
@Input() theme: string;
@Input() templateSelection: Select2TemplateFunction;
@Input() templateResult: Select2TemplateFunction;

// all additional options
@Input() options: Select2Options;

// emitter when value is changed
@Output() valueChanged = new EventEmitter();

private element: JQuery = undefined;
private check: boolean = false;

constructor(private renderer: Renderer) {}
constructor(private renderer: Renderer) { }

ngOnChanges(changes: SimpleChanges) {
if(!this.element) {
Expand Down Expand Up @@ -573,7 +575,6 @@ export class Select2Component implements AfterViewInit, OnChanges, OnDestroy {
if(!this.check) {
this.check = true;
console.log("Please add Select2 library (js file) to the project. You can download it from https://github.com/select2/select2/tree/master/dist/js.");

}

return;
Expand All @@ -585,12 +586,11 @@ export class Select2Component implements AfterViewInit, OnChanges, OnDestroy {
this.renderer.setElementProperty(this.selector.nativeElement, 'innerHTML', '');
}

this.element.select2({
let options: Select2Options = {
data: this.data,
templateResult: this.templateResult,
templateSelection: this.templateSelection,
theme: (this.theme) ? this.theme : 'default',
width: (this.width) ? this.width : 'resolve'
});
};

this.element.select2(Object.assign(options, this.options));
}
}

0 comments on commit 223f02f

Please sign in to comment.