From cccb9313df78cdd11925fbca057428782788068f Mon Sep 17 00:00:00 2001 From: Alex Rickabaugh Date: Mon, 2 Nov 2015 11:35:47 -0800 Subject: [PATCH 1/2] fix(forms): Export the NG_VALUE_ACCESSOR binding token. This is needed to allow component authors to implement custom ControlValueAccessors for their input components. --- modules/angular2/src/core/forms.ts | 2 +- modules/angular2/test/public_api_spec.ts | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/modules/angular2/src/core/forms.ts b/modules/angular2/src/core/forms.ts index 8e82ce44b07d..594c410f2b6d 100644 --- a/modules/angular2/src/core/forms.ts +++ b/modules/angular2/src/core/forms.ts @@ -24,7 +24,7 @@ export {NgControl} from './forms/directives/ng_control'; export {NgControlGroup} from './forms/directives/ng_control_group'; export {NgFormModel} from './forms/directives/ng_form_model'; export {NgForm} from './forms/directives/ng_form'; -export {ControlValueAccessor} from './forms/directives/control_value_accessor'; +export {ControlValueAccessor, NG_VALUE_ACCESSOR} from './forms/directives/control_value_accessor'; export {DefaultValueAccessor} from './forms/directives/default_value_accessor'; export {NgControlStatus} from './forms/directives/ng_control_status'; export {CheckboxControlValueAccessor} from './forms/directives/checkbox_value_accessor'; diff --git a/modules/angular2/test/public_api_spec.ts b/modules/angular2/test/public_api_spec.ts index 9d13af6e097d..ce29d3913909 100644 --- a/modules/angular2/test/public_api_spec.ts +++ b/modules/angular2/test/public_api_spec.ts @@ -821,6 +821,7 @@ var NG_ALL = [ 'LowerCasePipe', 'LowerCasePipe.transform()', 'NG_VALIDATORS', + 'NG_VALUE_ACCESSOR', 'NG_ASYNC_VALIDATORS', 'NgClass', 'NgClass.doCheck()', From 82c9bef8c24e3fb3ab441a1457667b298ae37fc2 Mon Sep 17 00:00:00 2001 From: Alex Rickabaugh Date: Mon, 2 Nov 2015 11:37:04 -0800 Subject: [PATCH 2/2] feat(forms): Use the DefaultValueAccessor for controls with an ng-default-control attribute. Third party controls require a ControlValueAccessor to function with Angular Forms. Many of them, like Polymer's , behave like the native element and thus can use the DefaultValueAccessor. Adding an ng-default-control attribute will now allow them to use that directive. --- .../src/core/forms/directives/default_value_accessor.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/angular2/src/core/forms/directives/default_value_accessor.ts b/modules/angular2/src/core/forms/directives/default_value_accessor.ts index fa23a0870e72..3d5c86f97e51 100644 --- a/modules/angular2/src/core/forms/directives/default_value_accessor.ts +++ b/modules/angular2/src/core/forms/directives/default_value_accessor.ts @@ -20,7 +20,7 @@ const DEFAULT_VALUE_ACCESSOR = CONST_EXPR(new Provider( */ @Directive({ selector: - 'input:not([type=checkbox])[ng-control],textarea[ng-control],input:not([type=checkbox])[ng-form-control],textarea[ng-form-control],input:not([type=checkbox])[ng-model],textarea[ng-model]', + 'input:not([type=checkbox])[ng-control],textarea[ng-control],input:not([type=checkbox])[ng-form-control],textarea[ng-form-control],input:not([type=checkbox])[ng-model],textarea[ng-model],[ng-default-control]', // TODO: vsavkin replace the above selector with the one below it once // https://github.com/angular/angular/issues/3011 is implemented // selector: '[ng-control],[ng-model],[ng-form-control]',