I have Angular reactive form, where every input is a separated component which receive parent form as @Input(). Inside this component I want to subscribe to his errors, and change variable value, if there is some errors. Errors for every control can came not only from value change, so I can't check errors on blur or on value change. What is the correct way to do this?
form.html
<form [formGroup]="formName">
<app-input-group [parentForm]="formName" [name]="controlName"></app-input-group>
</form>
input-group.ts
export class InputGroupComponent {
@Input parentForm: FormGroup
@Input name: string
public status: string
// Need to call this function when control in form have errors
public getStatus() {
if (this.parentForm.get(this.name).errors) {
this.status = 'suspended'
} else {
this.status = 'boosted'
}
}
}