-
Notifications
You must be signed in to change notification settings - Fork 27.1k
Closed
Description
I'm submitting a...
[X] Feature requestProposal
I could not find an existing issue/RFC for this: wouldn't it be a good idea to have more generics in @angular/forms?
export interface ControlValueAccessor<T = any> {
writeValue(value: T): void;
registerOnChange(fn: (value: T) => void): void;
registerOnTouched(fn: () => void): void;
setDisabledState?(isDisabled: boolean): void;
}
export interface Validator<T = any> {
validate(c: AbstractControl<T>): ValidationErrors|null;
registerOnValidatorChange?(fn: () => void): void;
}
export abstract class AbstractControl<T = any> {
public readonly value: T;
// ...
}What is the motivation / use case for changing the behavior?
The addition of optional generics should make it easier to implement your own NG_VALUE_ACCESSOR or NG_VALIDATOR:
class ColorPickerComponent implements ControlValueAccessor<Color> {
color: Color;
writeValue(color: Color): void {
this.color = color;
}
// ...
}Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels