In case of Model Driven form or Reactive form we can bind the custom error to an input field as follows:
In Component:
sampleForm.controls["formControlName"].setErrors({ 'incorrect': true })
;
My question is how can we do the same thing in case of Template Driven form?
You can make use of
View Child
in this scenario get an instance of thengForm
in the component backend model and then add all the validations and errors to itSomething like this
For More detailed info check my ts file which i created for such a scenario
link