Answer the question
In order to leave comments, you need to log in
Why pass this again to the custom form validator?
Please help me figure it out.
LIVE DEMO
I have a form with two fields. A custom validator hangs on one of the fields. In the list of validators, I write it like this: this.customValidator()
However, the built-in linter says that you need to pass an argument. But the validator function doesn't accept this, so I don't understand why we need to pass it. This is not clear
. If I write the validator call like this.customValidator() , then it is executed in the context of this. Because this comes before the dot. Therefore, I see no point in writing
With which, by the way, there is no syntax error. This is also incomprehensiblethis.floorValidator.bind(this)
Answer the question
In order to leave comments, you need to log in
You don't have to transfer anything. And you don’t need to call the validator when passing it to the FormControl constructor (do you really still not understand the difference between a function and calling it?).
What you forgot is to return some result from the validator. For example .
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question