How can we access the entire form inside a validator function.
i tried giving control.parent.parent ,but its throwing an error.
private unitNumberValidator(hasMdu){
return (control: AbstractControl)=>{
let returnVal = null;
//here i want to access entire form
console.log(control.parent.parent);
return returnVal;
}
}
how can we achieve this? Thanks
Just use
root
getter like:https://angular.io/api/forms/AbstractControl#root