Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(forms): Make reactive form directives standalone #55321

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 6 additions & 6 deletions goldens/public-api/forms/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ export class FormArrayName extends ControlContainer implements OnInit, OnDestroy
ngOnInit(): void;
get path(): string[];
// (undocumented)
static ɵdir: i0.ɵɵDirectiveDeclaration<FormArrayName, "[formArrayName]", never, { "name": { "alias": "formArrayName"; "required": false; }; }, {}, never, never, false, never>;
static ɵdir: i0.ɵɵDirectiveDeclaration<FormArrayName, "[formArrayName]", never, { "name": { "alias": "formArrayName"; "required": false; }; }, {}, never, never, true, never>;
// (undocumented)
static ɵfac: i0.ɵɵFactoryDeclaration<FormArrayName, [{ optional: true; host: true; skipSelf: true; }, { optional: true; self: true; }, { optional: true; self: true; }]>;
}
Expand Down Expand Up @@ -368,7 +368,7 @@ export class FormControlDirective extends NgControl implements OnChanges, OnDest
viewModel: any;
viewToModelUpdate(newValue: any): void;
// (undocumented)
static ɵdir: i0.ɵɵDirectiveDeclaration<FormControlDirective, "[formControl]", ["ngForm"], { "form": { "alias": "formControl"; "required": false; }; "isDisabled": { "alias": "disabled"; "required": false; }; "model": { "alias": "ngModel"; "required": false; }; }, { "update": "ngModelChange"; }, never, never, false, never>;
static ɵdir: i0.ɵɵDirectiveDeclaration<FormControlDirective, "[formControl]", ["ngForm"], { "form": { "alias": "formControl"; "required": false; }; "isDisabled": { "alias": "disabled"; "required": false; }; "model": { "alias": "ngModel"; "required": false; }; }, { "update": "ngModelChange"; }, never, never, true, never>;
// (undocumented)
static ɵfac: i0.ɵɵFactoryDeclaration<FormControlDirective, [{ optional: true; self: true; }, { optional: true; self: true; }, { optional: true; self: true; }, { optional: true; }, { optional: true; }]>;
}
Expand All @@ -391,7 +391,7 @@ export class FormControlName extends NgControl implements OnChanges, OnDestroy {
update: EventEmitter<any>;
viewToModelUpdate(newValue: any): void;
// (undocumented)
static ɵdir: i0.ɵɵDirectiveDeclaration<FormControlName, "[formControlName]", never, { "name": { "alias": "formControlName"; "required": false; }; "isDisabled": { "alias": "disabled"; "required": false; }; "model": { "alias": "ngModel"; "required": false; }; }, { "update": "ngModelChange"; }, never, never, false, never>;
static ɵdir: i0.ɵɵDirectiveDeclaration<FormControlName, "[formControlName]", never, { "name": { "alias": "formControlName"; "required": false; }; "isDisabled": { "alias": "disabled"; "required": false; }; "model": { "alias": "ngModel"; "required": false; }; }, { "update": "ngModelChange"; }, never, never, true, never>;
// (undocumented)
static ɵfac: i0.ɵɵFactoryDeclaration<FormControlName, [{ optional: true; host: true; skipSelf: true; }, { optional: true; self: true; }, { optional: true; self: true; }, { optional: true; self: true; }, { optional: true; }]>;
}
Expand Down Expand Up @@ -504,7 +504,7 @@ export class FormGroupDirective extends ControlContainer implements Form, OnChan
readonly submitted: boolean;
updateModel(dir: FormControlName, value: any): void;
// (undocumented)
static ɵdir: i0.ɵɵDirectiveDeclaration<FormGroupDirective, "[formGroup]", ["ngForm"], { "form": { "alias": "formGroup"; "required": false; }; }, { "ngSubmit": "ngSubmit"; }, never, never, false, never>;
static ɵdir: i0.ɵɵDirectiveDeclaration<FormGroupDirective, "[formGroup]", ["ngForm"], { "form": { "alias": "formGroup"; "required": false; }; }, { "ngSubmit": "ngSubmit"; }, never, never, true, never>;
// (undocumented)
static ɵfac: i0.ɵɵFactoryDeclaration<FormGroupDirective, [{ optional: true; self: true; }, { optional: true; self: true; }, { optional: true; }]>;
}
Expand All @@ -514,7 +514,7 @@ export class FormGroupName extends AbstractFormGroupDirective implements OnInit,
constructor(parent: ControlContainer, validators: (Validator | ValidatorFn)[], asyncValidators: (AsyncValidator | AsyncValidatorFn)[]);
name: string | number | null;
// (undocumented)
static ɵdir: i0.ɵɵDirectiveDeclaration<FormGroupName, "[formGroupName]", never, { "name": { "alias": "formGroupName"; "required": false; }; }, {}, never, never, false, never>;
static ɵdir: i0.ɵɵDirectiveDeclaration<FormGroupName, "[formGroupName]", never, { "name": { "alias": "formGroupName"; "required": false; }; }, {}, never, never, true, never>;
// (undocumented)
static ɵfac: i0.ɵɵFactoryDeclaration<FormGroupName, [{ optional: true; host: true; skipSelf: true; }, { optional: true; self: true; }, { optional: true; self: true; }]>;
}
Expand Down Expand Up @@ -833,7 +833,7 @@ export class ReactiveFormsModule {
// (undocumented)
static ɵinj: i0.ɵɵInjectorDeclaration<ReactiveFormsModule>;
// (undocumented)
static ɵmod: i0.ɵɵNgModuleDeclaration<ReactiveFormsModule, [typeof i5_2.FormControlDirective, typeof i6_2.FormGroupDirective, typeof i7_2.FormControlName, typeof i8_2.FormGroupName, typeof i8_2.FormArrayName], never, [typeof i4_2.ɵInternalFormsSharedModule, typeof i5_2.FormControlDirective, typeof i6_2.FormGroupDirective, typeof i7_2.FormControlName, typeof i8_2.FormGroupName, typeof i8_2.FormArrayName]>;
static ɵmod: i0.ɵɵNgModuleDeclaration<ReactiveFormsModule, never, [typeof i5_2.FormControlDirective, typeof i6_2.FormGroupDirective, typeof i7_2.FormControlName, typeof i8_2.FormGroupName, typeof i8_2.FormArrayName], [typeof i4_2.ɵInternalFormsSharedModule, typeof i5_2.FormControlDirective, typeof i6_2.FormGroupDirective, typeof i7_2.FormControlName, typeof i8_2.FormGroupName, typeof i8_2.FormArrayName]>;
}

// @public
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,12 @@ const formControlBinding: Provider = {
* @ngModule ReactiveFormsModule
* @publicApi
*/
@Directive({selector: '[formControl]', providers: [formControlBinding], exportAs: 'ngForm'})
@Directive({
selector: '[formControl]',
providers: [formControlBinding],
exportAs: 'ngForm',
standalone: true,
})
export class FormControlDirective extends NgControl implements OnChanges, OnDestroy {
/**
* Internal reference to the view model value.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ const controlNameBinding: Provider = {
* @ngModule ReactiveFormsModule
* @publicApi
*/
@Directive({selector: '[formControlName]', providers: [controlNameBinding]})
@Directive({selector: '[formControlName]', providers: [controlNameBinding], standalone: true})
export class FormControlName extends NgControl implements OnChanges, OnDestroy {
private _added = false;
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ const formDirectiveProvider: Provider = {
selector: '[formGroup]',
providers: [formDirectiveProvider],
host: {'(submit)': 'onSubmit($event)', '(reset)': 'onReset()'},
exportAs: 'ngForm'
exportAs: 'ngForm',
standalone: true,
})
export class FormGroupDirective extends ControlContainer implements Form, OnChanges, OnDestroy {
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ const formGroupNameProvider: Provider = {
* @ngModule ReactiveFormsModule
* @publicApi
*/
@Directive({selector: '[formGroupName]', providers: [formGroupNameProvider]})
@Directive({selector: '[formGroupName]', providers: [formGroupNameProvider], standalone: true})
export class FormGroupName extends AbstractFormGroupDirective implements OnInit, OnDestroy {
/**
* @description
Expand Down Expand Up @@ -131,7 +131,7 @@ export const formArrayNameProvider: any = {
* @ngModule ReactiveFormsModule
* @publicApi
*/
@Directive({selector: '[formArrayName]', providers: [formArrayNameProvider]})
@Directive({selector: '[formArrayName]', providers: [formArrayNameProvider], standalone: true})
export class FormArrayName extends ControlContainer implements OnInit, OnDestroy {
/** @internal */
_parent: ControlContainer;
Expand Down
2 changes: 1 addition & 1 deletion packages/forms/src/form_providers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export class FormsModule {
* @publicApi
*/
@NgModule({
declarations: [REACTIVE_DRIVEN_DIRECTIVES],
imports: [REACTIVE_DRIVEN_DIRECTIVES],
exports: [InternalFormsSharedModule, REACTIVE_DRIVEN_DIRECTIVES]
})
export class ReactiveFormsModule {
Expand Down