diff --git a/src/combo-box.component.ts b/src/combo-box.component.ts
index eb5386c..7664094 100644
--- a/src/combo-box.component.ts
+++ b/src/combo-box.component.ts
@@ -1,6 +1,6 @@
import {Component, OnInit, Input, Output, EventEmitter, forwardRef, ViewChild} from '@angular/core';
import {Observable, Subscription} from 'rxjs/Rx';
-import {ControlValueAccessor, NG_VALUE_ACCESSOR} from '@angular/forms';
+import {AbstractControl, ControlValueAccessor, NG_VALIDATORS, NG_VALUE_ACCESSOR, Validator} from '@angular/forms';
@Component({
moduleId: 'ng2-combobox',
@@ -12,12 +12,12 @@ import {ControlValueAccessor, NG_VALUE_ACCESSOR} from '@angular/forms';
(keydown)="onKeyDown($event)"
(blur)="onFieldBlur($event)"
(focus)="onFieldFocus()">
-
+
-
+
ComboBoxComponent),
multi: true
+ },
+ {
+ provide: NG_VALIDATORS,
+ useExisting: forwardRef(() => ComboBoxComponent),
+ multi: true
}]
})
-export class ComboBoxComponent implements ControlValueAccessor, OnInit {
+export class ComboBoxComponent implements ControlValueAccessor, OnInit, Validator {
@Input()
displayField: string;
@@ -142,6 +147,7 @@ export class ComboBoxComponent implements ControlValueAccessor, OnInit {
hideList: boolean = true;
data: any[];
+ valid: boolean = false;
private _loading: boolean = false;
private _listDataSubscription: Subscription;
@@ -160,6 +166,10 @@ export class ComboBoxComponent implements ControlValueAccessor, OnInit {
private propagateChange = (_: any) => {
};
+ // Validator props
+ private propagateValidate = () => {
+ };
+
constructor() {
}
@@ -187,9 +197,15 @@ export class ComboBoxComponent implements ControlValueAccessor, OnInit {
});
} else {
let data =