I have created the form group as below
import { setPwd } from './validators';
@Component({
....
export class pwdComp {
...
this.userFormPassword = this.fb.group({
'password': ['', [ setPwd ]]
});
In my another ts file has the setPwd
method
export function setPwd(c: FormControl) {
const SINGLE_LETTER_NUMERAL = /^\=\?$/;
return SINGLE_LETTER_NUMERAL.test(c.value) ? null : {
pwd: {
valid: false
}
};
}
The above script is working fine. But now my new scenario is I want to pass the pattern attribute to the setPwd
method, So I tried as below
this.userFormPassword = this.fb.group({
'password': ['', [ setPwd('**') ]]
});
and the setPwd
method is
export function setPwd(c: FormControl, newPattern) {
But it is throwing the error. How to pass the extra value to the external function.