Skip to content

Commit ccd8c57

Browse files
author
Stijn Goethals
committed
ts-lint fixs
1 parent 3375366 commit ccd8c57

File tree

3 files changed

+38
-39
lines changed

3 files changed

+38
-39
lines changed

index.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
1-
import { NgModule } from '@angular/core';
21
import { CommonModule } from '@angular/common';
2+
import { NgModule } from '@angular/core';
3+
34
import { NgSelect2Component } from './ng-select2/ng-select2.component';
45

56
@NgModule({
67
imports: [
7-
CommonModule
8+
CommonModule,
89
],
910
exports: [
10-
NgSelect2Component
11+
NgSelect2Component,
1112
],
1213
declarations: [
13-
NgSelect2Component
14-
]
14+
NgSelect2Component,
15+
],
1516
})
1617
export class NgSelect2Module { }

ng-select2/ng-select2.component.ts

Lines changed: 25 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,26 @@
11
/// <reference types="select2" />
22
import {
3+
forwardRef,
34
AfterViewInit,
45
ChangeDetectionStrategy,
56
Component,
7+
DoCheck,
68
ElementRef,
79
EventEmitter,
810
Input,
11+
NgZone,
912
OnChanges,
10-
DoCheck,
1113
OnDestroy,
14+
OnInit,
1215
Output,
16+
Renderer,
1317
SimpleChanges,
1418
ViewChild,
1519
ViewEncapsulation,
16-
Renderer,
17-
OnInit,
18-
forwardRef,
19-
NgZone,
20-
Self
2120
} from '@angular/core';
22-
import { ControlValueAccessor, NG_VALUE_ACCESSOR, NgControl } from '@angular/forms';
23-
import { Select2OptionData } from './ng-select2.interface';
21+
import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms';
2422
import { Options } from 'select2';
23+
import { Select2OptionData } from './ng-select2.interface';
2524

2625
declare var jQuery: any;
2726

@@ -34,9 +33,9 @@ declare var jQuery: any;
3433
{
3534
provide: NG_VALUE_ACCESSOR,
3635
useExisting: forwardRef(() => NgSelect2Component),
37-
multi: true
38-
}
39-
]
36+
multi: true,
37+
},
38+
],
4039
})
4140
export class NgSelect2Component implements AfterViewInit, OnChanges, OnDestroy, OnInit, DoCheck, ControlValueAccessor {
4241
@ViewChild('selector') selector: ElementRef;
@@ -72,7 +71,7 @@ export class NgSelect2Component implements AfterViewInit, OnChanges, OnDestroy,
7271

7372
private element: any = undefined;
7473
private check = false;
75-
private style = `CSS`;
74+
// private style = `CSS`;
7675

7776
constructor(private renderer: Renderer, public zone: NgZone, public _element: ElementRef) {
7877
}
@@ -118,7 +117,7 @@ export class NgSelect2Component implements AfterViewInit, OnChanges, OnDestroy,
118117
this.setElementValue(newValue);
119118
this.valueChanged.emit({
120119
value: newValue,
121-
data: this.element.select2('data')
120+
data: this.element.select2('data'),
122121
});
123122
this.propagateChange(newValue);
124123
}
@@ -155,11 +154,11 @@ export class NgSelect2Component implements AfterViewInit, OnChanges, OnDestroy,
155154

156155
this.element.on('select2:select select2:unselect', (e: any) => {
157156
// const newValue: string = (e.type === 'select2:unselect') ? '' : this.element.val();
158-
const newValue = this.element.val();
157+
const newValue = this.element.val();
159158

160159
this.valueChanged.emit({
161160
value: newValue,
162-
data: this.element.select2('data')
161+
data: this.element.select2('data'),
163162
});
164163
this.propagateChange(newValue);
165164
this.setElementValue(newValue);
@@ -188,14 +187,14 @@ export class NgSelect2Component implements AfterViewInit, OnChanges, OnDestroy,
188187

189188
let options: Options = {
190189
data: this.data,
191-
width: (this.width) ? this.width : 'resolve'
190+
width: (this.width) ? this.width : 'resolve',
192191
};
193192

194193
if (this.dropdownParent) {
195194
options = {
196195
data: this.data,
197196
width: (this.width) ? this.width : 'resolve',
198-
dropdownParent: jQuery('#' + this.dropdownParent)
197+
dropdownParent: jQuery('#' + this.dropdownParent),
199198
};
200199
}
201200

@@ -222,20 +221,18 @@ export class NgSelect2Component implements AfterViewInit, OnChanges, OnDestroy,
222221

223222
// this.zone.run(() => {
224223

225-
if (Array.isArray(newValue)) {
226-
227-
for (const option of this.selector.nativeElement.options) {
228-
this.renderer.setElementProperty(option, 'selected', (newValue.indexOf(option.value) > -1));
229-
}
230-
}
224+
if (Array.isArray(newValue)) {
231225

232-
else {
233-
this.renderer.setElementProperty(this.selector.nativeElement, 'value', newValue);
226+
for (const option of this.selector.nativeElement.options) {
227+
this.renderer.setElementProperty(option, 'selected', (newValue.indexOf(option.value) > -1));
234228
}
229+
} else {
230+
this.renderer.setElementProperty(this.selector.nativeElement, 'value', newValue);
231+
}
235232

236-
if(this.element) {
237-
this.element.trigger('change.select2');
238-
}
233+
if (this.element) {
234+
this.element.trigger('change.select2');
235+
}
239236
// });
240237
}
241238

ng-select2/ng-select2.interface.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
export interface Select2OptionData {
2-
id: string;
3-
text: string;
4-
disabled?: boolean;
5-
children?: Array<Select2OptionData>;
6-
additional?: any;
2+
id: string;
3+
text: string;
4+
disabled?: boolean;
5+
children?: Array<Select2OptionData>;
6+
additional?: any;
77
}
88

99
// export interface Select2TemplateFunction {
1010
// (state: Select2OptionData): JQuery | string;
11-
// }
11+
// }
12+

0 commit comments

Comments
 (0)