Home > Software engineering >  In Angular how can I pass two parameters into formControlName
In Angular how can I pass two parameters into formControlName

Time:03-16

I want to pass two parameters to the formControlName to make multiple cases like shown in the screenshot

CodePudding user response:

after showing your code this can't be possible, because you need two inputs for first and last name.

If you are taking both names in single input you can get in one control and separate using the javascript split feature.

CodePudding user response:

You can use the errors in the formcontrol for the validation. For example use errors.required in template for showing required validation. And please read about errors in formcontrol. We can't pass two formcontrolnames as you did in the image.

FormControl errors :- https://angular.io/api/forms/AbstractControl#errors.

You can set custom errors if you want. Using setErrors() method in formcontrol.You can watch for the change, set custom error and use it template. https://angular.io/api/forms/AbstractControl#seterrors

  • Related