I have a reactive form in my app and I was creating it like this:
this.myForm = new FormGroup({
name: new FormControl(this.item.name, Validators.required),
active: new FormControl(this.item.active),
value: new FormControl({ value: this.item.value, disabled: !this.item.active }, this.item.active ? Validators.required : null)
});
But now, I needed to add some custom validators to my form. So, I've changed my code to form builder like this:
this.myForm = this.fb.group({
name: [this.item.name],
active: [this.item.active],
value: [this.item.value, this.item.active ? Validators.required : null]
}, {validators: customValidator()});
I couldn't find how to set disabled attribute like above to below.