diff --git a/modules/angular2/src/forms/directives/checkbox_value_accessor.ts b/modules/angular2/src/forms/directives/checkbox_value_accessor.ts index 0cdec2544e..eb768c2b78 100644 --- a/modules/angular2/src/forms/directives/checkbox_value_accessor.ts +++ b/modules/angular2/src/forms/directives/checkbox_value_accessor.ts @@ -1,6 +1,7 @@ import {Renderer} from 'angular2/render'; import {Directive} from 'angular2/annotations'; import {ElementRef} from 'angular2/core'; +import {Self} from 'angular2/di'; import {NgControl} from './ng_control'; import {ControlValueAccessor} from './control_value_accessor'; @@ -30,10 +31,12 @@ import {setProperty} from './shared'; } }) export class CheckboxControlValueAccessor implements ControlValueAccessor { + private cd: NgControl; onChange = (_) => {}; onTouched = () => {}; - constructor(private cd: NgControl, private renderer: Renderer, private elementRef: ElementRef) { + constructor(@Self() cd: NgControl, private renderer: Renderer, private elementRef: ElementRef) { + this.cd = cd; cd.valueAccessor = this; } diff --git a/modules/angular2/src/forms/directives/default_value_accessor.ts b/modules/angular2/src/forms/directives/default_value_accessor.ts index 8e753c42db..4d8858d78b 100644 --- a/modules/angular2/src/forms/directives/default_value_accessor.ts +++ b/modules/angular2/src/forms/directives/default_value_accessor.ts @@ -1,6 +1,7 @@ import {Renderer} from 'angular2/render'; import {Directive} from 'angular2/annotations'; import {ElementRef} from 'angular2/core'; +import {Self} from 'angular2/di'; import {NgControl} from './ng_control'; import {ControlValueAccessor} from './control_value_accessor'; import {isBlank, isPresent} from 'angular2/src/facade/lang'; @@ -31,10 +32,12 @@ import {setProperty} from './shared'; } }) export class DefaultValueAccessor implements ControlValueAccessor { + private cd: NgControl; onChange = (_) => {}; onTouched = () => {}; - constructor(private cd: NgControl, private renderer: Renderer, private elementRef: ElementRef) { + constructor(@Self() cd: NgControl, private renderer: Renderer, private elementRef: ElementRef) { + this.cd = cd; cd.valueAccessor = this; } diff --git a/modules/angular2/src/forms/directives/select_control_value_accessor.ts b/modules/angular2/src/forms/directives/select_control_value_accessor.ts index 79bf463709..7366ddbdd8 100644 --- a/modules/angular2/src/forms/directives/select_control_value_accessor.ts +++ b/modules/angular2/src/forms/directives/select_control_value_accessor.ts @@ -1,5 +1,6 @@ import {Renderer} from 'angular2/render'; import {ElementRef, QueryList} from 'angular2/core'; +import {Self} from 'angular2/di'; import {Query, Directive} from 'angular2/annotations'; import {NgControl} from './ng_control'; @@ -40,14 +41,15 @@ export class NgSelectOption { } }) export class SelectControlValueAccessor implements ControlValueAccessor { + private cd: NgControl; value: string; onChange = (_) => {}; onTouched = () => {}; - constructor(private cd: NgControl, private renderer: Renderer, private elementRef: ElementRef, + constructor(@Self() cd: NgControl, private renderer: Renderer, private elementRef: ElementRef, @Query(NgSelectOption, {descendants: true}) query: QueryList) { + this.cd = cd; cd.valueAccessor = this; - this._updateValueWhenListOfOptionsChanges(query); }