Please help me inorder to implement below requirement.
I have developed model driven forms using angular 2 and tried to perform dynamic conditional required field validations.
Please find my plunker here.
I have one drop down and two input controls in my sample code.My requirement is :
1. When user selects foreign option in select box ,I should apply required validator for house number and building name in component class.
2. When user selects local option in select box , I should remove required validator for house number and building name. But minlength ,pattern validations should be applied to the controls.(If user doesn't enter the data then no problem. If user enter data in house number and building name even though those are optional I should validate pattern and minlength etc...)
Note: My select box data is not static , In my real time requirement I will get the data from service and binds the data to it. In sample I have used only two options for easy understanding.