How do I set validators on a nested FormControl with child objects? This product below, actually has members: productId, productName, productDescription (coming from a dropdown select) I want to set validators productId > 4 .
this.editSharedForm = this.formBuilder.group({
'customerName':[null,[Validators.maxLength(50)],
'customerPhone': [null, [Validators.maxLength(10)]],
'product': new FormControl('')
Following is not working:
this.editSharedForm.get('product').get('productId').setValidators(Validators.min(5))
this.editSharedForm.get('product').value['productId'].setValidators(Validators.min(5))
Errors being Undefined error for first one, not a function for second command.
productwhere isproductId?this.editSharedForm.get('product').setValidators(yourValidators)and then callthis.editSharedForm.get('product').updateValueAndValidity()in order to run the new validators.