cleanup(forms): value accessors inject NgControl only from self
This commit is contained in:
		
							parent
							
								
									469afda53e
								
							
						
					
					
						commit
						45b10a1f0f
					
				| @ -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; | ||||
|   } | ||||
| 
 | ||||
|  | ||||
| @ -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; | ||||
|   } | ||||
| 
 | ||||
|  | ||||
| @ -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<NgSelectOption>) { | ||||
|     this.cd = cd; | ||||
|     cd.valueAccessor = this; | ||||
| 
 | ||||
|     this._updateValueWhenListOfOptionsChanges(query); | ||||
|   } | ||||
| 
 | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user