Skip to content

Commit 4e40ac3

Browse files
committed
Fixes #28
1 parent 093564c commit 4e40ac3

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "ng2-select2",
3-
"version": "0.6.1",
3+
"version": "0.6.2",
44
"description": "Angular2 wrapper for select2",
55
"main": "ng2-select2.js",
66
"typings": "ng2-select2.d.ts",

src/select2.component.ts

+5-4
Original file line numberDiff line numberDiff line change
@@ -502,7 +502,7 @@ import { Select2OptionData, Select2TemplateFunction } from './select2.interface'
502502
export class Select2Component implements AfterViewInit {
503503
@ViewChild('selector') selector: ElementRef;
504504

505-
// data for select2 dropdown
505+
// data for select2 drop down
506506
@Input() data: Array<Select2OptionData>;
507507
@Input() value: any;
508508

@@ -515,13 +515,13 @@ export class Select2Component implements AfterViewInit {
515515
@Input() templateSelection: Select2TemplateFunction;
516516
@Input() templateResult: Select2TemplateFunction;
517517

518-
private element: JQuery;
518+
private element: JQuery = undefined;
519519

520520
ngOnChanges(changes: SimpleChanges) {
521-
if(this.element && changes['data'] && changes['data'].previousValue !== changes['data'].currentValue) {
521+
if(this.element && changes['data'] && JSON.stringify(changes['data'].previousValue) !== JSON.stringify(changes['data'].currentValue)) {
522522
this.initPlugin();
523-
this.element.trigger("change");
524523
}
524+
525525
if(this.element && changes['value'] && changes['value'].previousValue !== changes['value'].currentValue) {
526526
this.element.val(changes['value'].currentValue);
527527
this.element.trigger('change');
@@ -555,6 +555,7 @@ export class Select2Component implements AfterViewInit {
555555
this.element.select2('destroy');
556556
this.element.html('')
557557
}
558+
558559
this.element.select2({
559560
data: this.data,
560561
templateResult: this.templateResult,

0 commit comments

Comments
 (0)