You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Which @angular/* package(s) are relevant/related to the feature request?
@angular/forms
Description
I am building a set of configurable form field components that uses the directive composition API. I want to reuse Angular's built-in validator directives to define what validators are applicable to each field without re-implementing them in each form field component.
@Component({standalone: true,selector: 'form-field[type="project-id"]',imports: [MatFormFieldModule,MatInputModule,ReactiveFormsModule],template: ` <mat-form-field> <mat-label>Project ID</mat-label> <input matInput [formControl]="control" /> @if (control.hasError('required')) { <mat-error>Project ID is required</mat-error> } </mat-form-field> `,hostDirectives: [{directive: RequiredValidator,// TS-992014: Host directive RequiredValidator must be standaloneinputs: ['required']},{directive: FormFieldDirective// implements ControlValueAccessor}],providers: provideFormField(ProjectIdFieldComponent),})exportclassProjectIdFieldComponent{control=newFormControl();}
Can you provide a real word example where this isn't sufficient ? Thank you.
Edit: Actually MaxValidator, MinValidator, CheckboxRequiredValidator do only match [input].... So the issue is only for those 3 validators. RequiredValidator, PatternValidator, MaxLengthValidator & MinLengthValidators work fine on custom components.
Which @angular/* package(s) are relevant/related to the feature request?
@angular/forms
Description
I am building a set of configurable form field components that uses the directive composition API. I want to reuse Angular's built-in validator directives to define what validators are applicable to each field without re-implementing them in each form field component.
Related issue: #51248
Proposed solution
Add the standalone flag to existing validator directives.
Alternatives considered
I am currently converting these to standalone directives myself.
The text was updated successfully, but these errors were encountered: