Reputation: 6852
Is it possible to display validators error message inside html template I have something like this
this.formBuilder.group({
sizeOfBuildingPart: [{ value: 0, disabled:false }, [Validators.min(0),Validators.max(100), Validators.required, Validators.pattern('[0-9]*$')]]});
In html template I need to display error message if max value is bigger then validators
Something like this
{{formControls.sizeOfBuildingPart.errors?.max}}
It is working ok, but is it possible to display what is max number value (in this case 100), tried something like this
{{formControls.sizeOfBuildingPart.errors?.max.value}}
But it does not work, thanks in advance
Upvotes: 0
Views: 772
Reputation: 1843
You need to use : (form.controls['sizeOfBuildingPart'].errors?.max?.max) That will return you max number provided in validations.
Here is working demo for it: stackblitz
Upvotes: 2