@@ -8,9 +8,15 @@ import {forwardRef, Host, SkipSelf, Provider, Inject, Optional} from 'angular2/s
88import { ControlContainer } from './control_container' ;
99import { NgControl } from './ng_control' ;
1010import { ControlValueAccessor , NG_VALUE_ACCESSOR } from './control_value_accessor' ;
11- import { controlPath , composeValidators , isPropertyUpdated , selectValueAccessor } from './shared' ;
11+ import {
12+ controlPath ,
13+ composeValidators ,
14+ composeAsyncValidators ,
15+ isPropertyUpdated ,
16+ selectValueAccessor
17+ } from './shared' ;
1218import { Control } from '../model' ;
13- import { Validators , NG_VALIDATORS } from '../validators' ;
19+ import { Validators , NG_VALIDATORS , NG_ASYNC_VALIDATORS } from '../validators' ;
1420
1521
1622const controlNameBinding =
@@ -81,21 +87,18 @@ const controlNameBinding =
8187export class NgControlName extends NgControl implements OnChanges ,
8288 OnDestroy {
8389 /** @internal */
84- _parent : ControlContainer ;
8590 update = new EventEmitter ( ) ;
8691 model : any ;
8792 viewModel : any ;
88- private _validator : Function ;
89- /** @internal */
90- _added = false ;
93+ private _added = false ;
9194
92- constructor ( @Host ( ) @SkipSelf ( ) parent : ControlContainer ,
93- @Optional ( ) @Inject ( NG_VALIDATORS ) validators :
95+ constructor ( @Host ( ) @SkipSelf ( ) private _parent : ControlContainer ,
96+ @Optional ( ) @Inject ( NG_VALIDATORS ) private _validators :
97+ /* Array<Validator|Function> */ any [ ] ,
98+ @Optional ( ) @Inject ( NG_ASYNC_VALIDATORS ) private _asyncValidators :
9499 /* Array<Validator|Function> */ any [ ] ,
95100 @Optional ( ) @Inject ( NG_VALUE_ACCESSOR ) valueAccessors : ControlValueAccessor [ ] ) {
96101 super ( ) ;
97- this . _parent = parent ;
98- this . _validator = composeValidators ( validators ) ;
99102 this . valueAccessor = selectValueAccessor ( this , valueAccessors ) ;
100103 }
101104
@@ -121,7 +124,9 @@ export class NgControlName extends NgControl implements OnChanges,
121124
122125 get formDirective ( ) : any { return this . _parent . formDirective ; }
123126
124- get validator ( ) : Function { return this . _validator ; }
127+ get validator ( ) : Function { return composeValidators ( this . _validators ) ; }
128+
129+ get asyncValidator ( ) : Function { return composeAsyncValidators ( this . _asyncValidators ) ; }
125130
126131 get control ( ) : Control { return this . formDirective . getControl ( this ) ; }
127132}
0 commit comments