Hello, I have many similar forms, so i thought about creating an abstract service that would initialize a form with common properties, while a custom service would extend them. I thought of something like this:
interface BaseForm {
a: FormGroup<fg1>;
b: FormGroup<fg2>;
}
interface CustomForm extends BaseForm {
c: FormGroup<fg3>;
}
abstract class BaseInitService<T> {
protected form = new FormGroup<T>({
a: new FormGroup<fg1>({...});
b: new FormGroup<fg2>({...})
})
}
class CustomInitService extends BaseInitService<CustomForm>{
constructor() {
this.form.addControl('c',new FormGroup<fg3>({...}))
}
}
I don't have much experience with generics and inheritance and. The workaround i was thinking of was to add all possible formGroup as optional in the base interface and add individual controls in custom services, but... I want to find a better solution 😄